Skip to content

Commit

Permalink
Nowcoder: 2024牛客暑期多校训练营5
Browse files Browse the repository at this point in the history
  • Loading branch information
Macesuted committed Jul 31, 2024
1 parent fda0f9f commit 72f28a5
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Nowcoder/81600B.cpp
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;
}
41 changes: 41 additions & 0 deletions Nowcoder/81600E.cpp
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;
}
55 changes: 55 additions & 0 deletions Nowcoder/81600H.cpp
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;
}

0 comments on commit 72f28a5

Please sign in to comment.