Task: | Peli |
Sender: | MikaelM |
Submission time: | 2024-01-20 16:57:43 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.00 s | 1, 2 | details |
#2 | WRONG ANSWER | 0.00 s | 1, 2 | details |
#3 | WRONG ANSWER | 0.10 s | 2 | details |
#4 | WRONG ANSWER | 0.00 s | 1, 2 | details |
#5 | WRONG ANSWER | 0.00 s | 1, 2 | details |
#6 | WRONG ANSWER | 0.10 s | 2 | details |
#7 | WRONG ANSWER | 0.10 s | 2 | details |
#8 | WRONG ANSWER | 0.00 s | 1, 2 | details |
#9 | WRONG ANSWER | 0.70 s | 2 | details |
#10 | WRONG ANSWER | 0.73 s | 2 | details |
Code
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2501; vector<int> v[N]; int z[N]; ll e[3][N][N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m, q; cin >> n >> m >> q; for(int i = 1; i <= m; i++){ int a, b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a); } for(int i = 1; i <= n; i++){ for(int j = 0; j < 3; j++){ e[j][i][i] = 1e18; } } for(int s = 1; s <= n; s++){ queue<int> q; q.push(s); e[1][s][s] = e[0][s][s] = 0; while(!q.empty()){ int a = q.front(); q.pop(); if(z[a] == 2) continue; z[a]++; // z[a] = monesko kerta tässä solmussa for(int u : v[a]){ q.push(u); e[z[u]][s][u] = e[z[u]][s][a] + 1; } } } while(q--){ bool ok = false; int a, b, x; cin >> a >> b >> x; if(a == b && x % 2 == 1) { cout << "NO\n"; continue; } if(e[0][a][b] > x){ cout << "NO\n"; continue; } if(x % 2 == 0){ if(e[0][a][b] % 2 == 0 || e[1][a][b] % 2 == 0){ cout << "YES\n"; continue; } for(int s = 1; s <= n; s++){ // molemmat parittomia tai parillisia if(e[0][a][s] % 2 == 0 || e[0][s][b] % 2 == 0){ cout << "YES";ok = true; break; } else if(e[1][a][s] % 2 == 0 || e[1][s][b] % 2 == 0){ cout << "YES";ok = true; break; } else if(e[1][a][s] % 2 == 1 || e[1][s][b] % 2 == 1){ cout << "YES";ok = true; break; } else if(e[1][a][s] % 2 == 1 || e[1][s][b] % 2 == 1){ cout << "YES";ok = true; break; } } } else{ if(e[0][a][b] % 2 == 1 || e[1][a][b] % 2 == 1){ cout << "YES\n"; continue; } for(int s = 1; s <= n; s++){ // toinen pariton ja toinen parillinen if((e[0][a][s] % 2 == 0 && e[0][s][b] % 2 == 1) || (e[0][a][s] % 2 == 1 && e[0][s][b] % 2 == 0)){ cout << "YES";ok = true; break; } else if((e[1][a][s] % 2 == 0 && e[1][s][b] % 2 == 1) || (e[1][a][s] % 2 == 1 && e[1][s][b] % 2 == 0)){ cout << "YES";ok = true; break; } } } if(!ok) cout << "NO"; cout << "\n"; } } /* 4 5 1 1 2 2 3 1 3 2 4 3 4 1 4 1 */
Test details
Test 1
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
2 1 100 1 2 1 1 0 1 2 0 2 1 0 ... |
correct output |
---|
YES NO NO YES NO ... |
user output |
---|
YES NO YES YES NO ... Truncated |
Test 2
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
50 49 100 33 34 7 8 49 50 47 48 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
YES YES YES YES YES ... Truncated |
Test 3
Group: 2
Verdict: WRONG ANSWER
input |
---|
2500 2499 100000 821 822 2351 2352 752 753 832 833 ... |
correct output |
---|
NO YES YES NO NO ... |
user output |
---|
YES YES YES YES YES ... Truncated |
Test 4
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
12 12 100 9 10 2 3 1 12 1 2 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
YES YES YES NO YES ... Truncated |
Test 5
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
11 11 100 10 11 7 8 1 2 5 6 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... Truncated |
Test 6
Group: 2
Verdict: WRONG ANSWER
input |
---|
2500 2500 100000 1936 1937 1884 1885 751 752 831 832 ... |
correct output |
---|
NO YES YES NO NO ... |
user output |
---|
YES YES YES YES YES ... Truncated |
Test 7
Group: 2
Verdict: WRONG ANSWER
input |
---|
2499 2499 100000 821 822 2351 2352 752 753 832 833 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... Truncated |
Test 8
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
50 99 100 40 47 34 50 44 47 15 16 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... Truncated |
Test 9
Group: 2
Verdict: WRONG ANSWER
input |
---|
2500 4999 100000 1191 2361 251 399 1026 2300 82 1655 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES NO NO ... Truncated |
Test 10
Group: 2
Verdict: WRONG ANSWER
input |
---|
2500 4999 100000 2023 2218 23 51 1020 1272 11 114 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES NO NO NO YES ... Truncated |