-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @file 81600B.cpp | ||
* @author Macesuted (i@macesuted.moe) | ||
* @date 2024-07-30 | ||
* | ||
* @copyright Copyright (c) 2024 | ||
* | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
#define endl '\n' | ||
|
||
bool solve(void) { | ||
int64_t n, m, a, b; | ||
cin >> n >> m >> a >> b, a = !a, b = !b; | ||
if (n > m) swap(n, m); | ||
|
||
if (n == 1 && m == 2) return true; | ||
if (n % 2 == 1 && m % 2 == 1) return false; | ||
|
||
if (a == 1 && b == 1) return false; | ||
if (a == 0 && b == 0) return true; | ||
if (a == 1) { | ||
if (n == 1) return false; | ||
return true; | ||
} | ||
if (b == 1) { | ||
if (n == 1) return true; | ||
return false; | ||
} | ||
return false; | ||
} | ||
|
||
int main() { | ||
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); | ||
|
||
int _ = 1; | ||
cin >> _; | ||
while (_--) cout << (solve() ? "Yes" : "No") << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @file 81600E.cpp | ||
* @author Macesuted (i@macesuted.moe) | ||
* @date 2024-07-30 | ||
* | ||
* @copyright Copyright (c) 2024 | ||
* | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
#define endl '\n' | ||
#define maxn 100005 | ||
|
||
int a[maxn], b[maxn]; | ||
|
||
void solve(void) { | ||
int n; | ||
cin >> n; | ||
for (int i = 1; i <= n; i++) cin >> a[i]; | ||
for (int i = 1; i <= n; i++) cin >> b[i]; | ||
int ans = 0, cnt = 0; | ||
for (int i = 1; i <= n; i++) | ||
if (a[i] > b[i]) | ||
ans++; | ||
else if (a[i] == b[i]) | ||
cnt++; | ||
cout << ans + ((cnt + 1) / 2) << endl; | ||
return; | ||
} | ||
|
||
int main() { | ||
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); | ||
|
||
int _ = 1; | ||
cin >> _; | ||
while (_--) solve(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @file 81600H.cpp | ||
* @author Macesuted (i@macesuted.moe) | ||
* @date 2024-07-30 | ||
* | ||
* @copyright Copyright (c) 2024 | ||
* | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
#define endl '\n' | ||
|
||
#define maxn 45 | ||
|
||
vector<vector<int>> graph; | ||
int64_t conn[maxn]; | ||
int ans; | ||
|
||
void dfs(int p, int64_t S = 0, int len = 0) { | ||
S |= (int64_t)1 << p, len++; | ||
ans = max(ans, len); | ||
for (auto q : graph[p]) | ||
if (!(S >> q & 1) && (conn[q] & S) == ((int64_t)1 << p)) dfs(q, S, len); | ||
return; | ||
} | ||
|
||
void solve(void) { | ||
int n, m; | ||
cin >> n >> m; | ||
graph.clear(), graph.resize(n + 1); | ||
|
||
for (int i = 1; i <= n; i++) conn[i] = 0; | ||
for (int i = 1, x, y; i <= m; i++) { | ||
cin >> x >> y; | ||
graph[x].push_back(y), graph[y].push_back(x); | ||
conn[x] |= (int64_t)1 << y; | ||
conn[y] |= (int64_t)1 << x; | ||
} | ||
ans = 0; | ||
for (int i = 1; i <= n; i++) dfs(i); | ||
cout << ans << endl; | ||
return; | ||
} | ||
|
||
int main() { | ||
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); | ||
|
||
int _ = 1; | ||
// cin >> _; | ||
while (_--) solve(); | ||
|
||
return 0; | ||
} |