QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#54675 | #4194. Killjoys' Conference | Sa3tElSefr# | AC ✓ | 514ms | 67316kb | C++ | 1.7kb | 2022-10-10 03:32:55 | 2022-10-10 03:32:56 |
Judging History
answer
/// tban lecodes el bosta2
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x,y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll
using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;
const int N = 2e5+5, LG = 18, MOD = 1e9+7;
const long double PI = acos(-1);
const long double EPS = 1e-7;
const string TARGET = "WALDO";
int col[1000006];
vector<int> adj[1000006];
bool dfs(int node, int c) {
if(col[node] != -1)
return col[node] == c;
col[node] = c;
for(auto v : adj[node])
if(!dfs(v, 1 - c))
return false;
return true;
}
void doWork() {
int n, m, p;
cin >> n >> m >> p;
f(i,0,m) {
int u, v;
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
memset(col, -1, sizeof col);
int ans = 1;
for(int i = 1; i <= n; i++)if(col[i] == -1) {
if(!dfs(i,0)) {
cout << "impossible\n";
return;
}
ans = ans * 2 % p;
}
ans = ans * ((p + 1) / 2) % p;
cout << (ans + 1) % p << '\n';
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int t = 1;
// cin >> t;
while (t--) {
doWork();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 8ms
memory: 34888kb
input:
4 2 11 1 2 3 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 15ms
memory: 34944kb
input:
5 2 3 1 2 3 4
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 10ms
memory: 34812kb
input:
3 3 11 1 2 2 3 3 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 4ms
memory: 34860kb
input:
100 0 13
output:
9
result:
ok single line: '9'
Test #5:
score: 0
Accepted
time: 21ms
memory: 34908kb
input:
1000000 0 999983
output:
131073
result:
ok single line: '131073'
Test #6:
score: 0
Accepted
time: 7ms
memory: 34848kb
input:
5 0 17
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 4ms
memory: 34852kb
input:
6 0 11
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 514ms
memory: 67316kb
input:
910292 929828 296851369 138316 521196 344174 594024 83412 434709 773248 836155 238718 422888 306559 904462 267860 898937 413132 488904 377100 725377 280966 647857 194879 226916 46886 181828 211614 264486 597301 659354 211498 340231 131349 463058 218728 850468 112991 832910 311079 403177 94372 457800...
output:
impossible
result:
ok single line: 'impossible'
Test #9:
score: 0
Accepted
time: 37ms
memory: 37036kb
input:
474415 39086 193520539 226365 326319 173587 188446 196237 384686 12130 438747 142687 240963 42823 198839 33523 441119 37690 269573 158873 264117 265666 307648 371107 470830 111014 416679 205426 259164 143776 337091 266405 399531 7332 293732 87282 131377 144755 269135 73861 213137 413795 429757 12293...
output:
24850764
result:
ok single line: '24850764'
Test #10:
score: 0
Accepted
time: 58ms
memory: 38940kb
input:
886771 69103 843021961 155346 347704 395735 428613 145842 769876 730641 854763 368391 433651 570964 775530 482006 716549 411782 547430 22514 663720 7673 93526 234498 340129 126566 579992 627671 739879 683991 787364 64669 613364 361636 539521 82596 581375 151505 311499 214280 232615 429695 706186 102...
output:
195055087
result:
ok single line: '195055087'
Test #11:
score: 0
Accepted
time: 40ms
memory: 37820kb
input:
261871 56947 37434461 181348 220749 60472 229420 22876 33088 78741 90153 52949 210249 82780 241798 19262 56861 83377 141486 199523 211244 144337 168415 124052 145687 21941 74986 138530 230058 108522 125335 24900 44205 40874 58680 27342 173854 96226 169565 42306 77188 88277 143247 35849 229572 28335 ...
output:
29316196
result:
ok single line: '29316196'
Test #12:
score: 0
Accepted
time: 65ms
memory: 40200kb
input:
730267 96959 263495809 161273 375572 255354 562714 173645 232299 282893 328384 211088 298409 8990 696289 431898 554175 678197 701660 10563 605490 263785 696678 133569 330504 121 635357 549515 559844 571064 698976 523289 710717 364053 423410 20210 423915 306989 357164 241145 404451 35863 426544 35402...
output:
183324026
result:
ok single line: '183324026'
Test #13:
score: 0
Accepted
time: 40ms
memory: 38768kb
input:
317597 79392 370638017 85444 281488 86255 250036 59640 187426 91541 197016 115564 151195 127964 281637 163111 256617 78576 275740 133367 292829 63773 108615 5562 102599 53140 145288 69160 93021 8925 186049 70808 268881 20656 254231 71089 203880 184543 237436 14565 67134 220007 234899 76369 270335 87...
output:
48131608
result:
ok single line: '48131608'
Test #14:
score: 0
Accepted
time: 7ms
memory: 34776kb
input:
10 10 999983 1 2 2 3 3 4 1 4 5 6 6 7 7 8 8 9 9 10 5 10
output:
3
result:
ok single line: '3'
Test #15:
score: 0
Accepted
time: 8ms
memory: 34836kb
input:
10 10 999983 1 2 1 2 3 4 3 4 5 6 6 7 7 8 8 9 9 10 5 10
output:
5
result:
ok single line: '5'
Test #16:
score: 0
Accepted
time: 4ms
memory: 34848kb
input:
11 10 999983 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 1 10
output:
3
result:
ok single line: '3'
Test #17:
score: 0
Accepted
time: 10ms
memory: 34928kb
input:
100 100 999983 1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 15 16 17 18 17 18 19 20 19 20 21 22 21 22 23 24 23 24 25 26 25 26 27 28 27 28 29 30 29 30 31 32 31 32 33 34 33 34 35 36 35 36 37 38 37 38 39 40 39 40 41 42 41 42 43 44 43 44 45 46 45 46 47 48 47 48 49 50 49 50 51 ...
output:
880025
result:
ok single line: '880025'
Test #18:
score: 0
Accepted
time: 5ms
memory: 34924kb
input:
1000 1000 999983 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 1 10 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 11 20 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 21 30 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 31 40 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 41 50 5...
output:
556666
result:
ok single line: '556666'
Test #19:
score: 0
Accepted
time: 12ms
memory: 35176kb
input:
10000 10000 999983 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
556666
result:
ok single line: '556666'
Test #20:
score: 0
Accepted
time: 38ms
memory: 37980kb
input:
100000 100000 999983 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 1 10 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 11 20 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 21 30 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 31 40 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 41 ...
output:
525518
result:
ok single line: '525518'