ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#205496 | #3657. 二分图 | Daniel1024 | 100 | 463ms | 7380kb | C++ | 786b | 2024-07-07 12:14:40 | 2024-07-07 13:19:47 |
answer
#include<bits/stdc++.h>
using namespace std;
int a, b, m;
vector<int>t[100005];
int have[100005];
int to[100005];
signed main(){
cin >> a >> b >> m;
for(int i = 1; i <= m; i++){
int x, y;
scanf("%d%d", &x, &y);
if(x == a)to[y] ^= 1;
else t[x].push_back(y);
}
for(int i = 1; i < a; i++){
int len = t[i].size();
for(int j = 0; j < len; j++){
have[i] ^= 1;
to[t[i][j]] ^= 1;
to[b] ^= 1;
}
}
int ans = 0;
int s1 = 0, s2 = 0;
for(int i = 1; i < a; i++)s1 += have[i];
for(int i = 1; i < b; i++)s2 += to[i];
ans = s1 + s2 - min(s1, s2);
if(min(s1, s2) & 1)to[b] ^= 1;
ans += to[b];
cout << ans << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 3636kb
input:
3 3 6 3 1 1 2 2 2 3 3 3 2 1 1
output:
2
result:
ok single line: '2'
Test #2:
score: 10
Accepted
time: 0ms
memory: 3640kb
input:
3 3 6 2 3 1 3 1 1 3 1 2 2 1 2
output:
2
result:
ok single line: '2'
Test #3:
score: 10
Accepted
time: 0ms
memory: 3644kb
input:
5 5 10 2 2 3 5 2 1 5 1 4 3 5 5 4 1 2 5 4 4 1 3
output:
4
result:
ok single line: '4'
Test #4:
score: 10
Accepted
time: 0ms
memory: 3640kb
input:
5 5 10 1 3 2 2 4 1 1 5 3 3 2 5 5 3 5 5 1 4 3 2
output:
4
result:
ok single line: '4'
Test #5:
score: 10
Accepted
time: 10ms
memory: 4088kb
input:
114 515 58710 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 ...
output:
114
result:
ok single line: '114'
Test #6:
score: 10
Accepted
time: 3ms
memory: 4092kb
input:
115 515 59225 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 ...
output:
515
result:
ok single line: '515'
Test #7:
score: 10
Accepted
time: 113ms
memory: 7284kb
input:
68944 65538 457334 28574 3442 25145 16846 3908 4208 1458 23374 6977 13895 15623 10242 5458 32462 147...
output:
16390
result:
ok single line: '16390'
Test #8:
score: 10
Accepted
time: 111ms
memory: 7336kb
input:
80715 54106 456937 6635 12392 6993 23015 16612 416 1154 31247 30337 8910 20012 15283 25326 8635 3175...
output:
16501
result:
ok single line: '16501'
Test #9:
score: 10
Accepted
time: 113ms
memory: 7380kb
input:
54914 55025 464166 7197 327 19912 4344 14147 30464 22874 24904 16761 27174 16591 1399 28037 9082 180...
output:
16416
result:
ok single line: '16416'
Test #10:
score: 10
Accepted
time: 113ms
memory: 7328kb
input:
80584 52252 456351 32761 6996 21358 22163 11514 9134 17800 13069 629 22725 8945 19723 9490 2413 2233...
output:
16395
result:
ok single line: '16395'
Extra Test:
score: 0
Extra Test Passed