QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#255410 | #7755. Game on a Forest | ucup-team037# | WA | 3ms | 10128kb | C++17 | 2.4kb | 2023-11-18 15:48:34 | 2023-11-18 15:48:35 |
Judging History
answer
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 200005;
int n, m;
vi adj[MAXN];
int cnt[2];
int ans;
int p[MAXN];
int vis[MAXN];
int sub[MAXN];
void dfs(int u) {
sub[u] = 1;
for (int v : adj[u]) {
if (vis[v]) {
continue;
}
vis[v] = vis[u];
p[v] = u;
dfs(v);
sub[u] ^= sub[v];
}
}
int main() {
#ifndef DEBUG
ios::sync_with_stdio(0), cin.tie(0);
#endif
cin >> n >> m;
REP (i, 0, m) {
int u, v; cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
REP (i, 1, n + 1) {
if (vis[i]) {
continue;
}
vis[i] = i;
dfs(i);
cnt[sub[i]] ^= 1;
}
REP (u, 1, n + 1) {
for (int v : adj[u]) {
if (v == p[u]) {
continue;
}
int tcnt[2] = {0, 0};
tcnt[sub[vis[v]]] ^= 1;
tcnt[sub[v]] ^= 1;
tcnt[sub[vis[v]] ^ sub[v]] ^= 1;
if (tcnt[0] == cnt[0] && tcnt[1] == cnt[1]) {
ans++;
}
}
int tcnt[2] = {0, 0};
tcnt[sub[vis[u]]] ^= 1;
int tot = sub[vis[u]] ^ 1;
for (int v : adj[u]) {
if (v == p[u]) {
continue;
}
tot ^= sub[v];
tcnt[sub[v]] ^= 1;
}
tcnt[tot] ^= 1;
if (tcnt[0] == cnt[0] && tcnt[1] == cnt[1]) {
ans++;
}
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9020kb
input:
3 1 1 2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2ms
memory: 10128kb
input:
4 3 1 2 2 3 3 4
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 3ms
memory: 9996kb
input:
100000 1 4647 17816
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 9052kb
input:
100000 2 64075 72287 63658 66936
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 9744kb
input:
100000 3 59930 72281 31689 59132 20469 33165
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 8968kb
input:
100000 10 20391 78923 27822 80617 21749 25732 12929 79693 42889 52515 59064 99869 29031 41875 4463 17813 13407 42498 19120 20957
output:
0
result:
ok 1 number(s): "0"
Test #7:
score: -100
Wrong Answer
time: 3ms
memory: 9780kb
input:
99999 101 34378 94161 67696 83255 24557 25591 11476 58475 5684 38157 33843 35321 9046 24028 14293 77681 587 42098 9402 27228 6999 13980 27118 84005 3622 8353 13545 51621 16998 63647 32912 53178 15206 15815 56517 86335 5563 93770 153 278 11242 41753 75098 76792 1695 22836 25936 33352 2765 6778 19597 ...
output:
99898
result:
wrong answer 1st numbers differ - expected: '200', found: '99898'