Task: | Peli |
Sender: | maweiyin24562 |
Submission time: | 2024-07-23 14:49:25 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 42 |
#2 | ACCEPTED | 58 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.04 s | 1, 2 | details |
#2 | ACCEPTED | 0.04 s | 1, 2 | details |
#3 | ACCEPTED | 0.44 s | 2 | details |
#4 | ACCEPTED | 0.04 s | 1, 2 | details |
#5 | ACCEPTED | 0.04 s | 1, 2 | details |
#6 | ACCEPTED | 0.42 s | 2 | details |
#7 | ACCEPTED | 0.55 s | 2 | details |
#8 | ACCEPTED | 0.04 s | 1, 2 | details |
#9 | ACCEPTED | 0.88 s | 2 | details |
#10 | ACCEPTED | 0.91 s | 2 | details |
Compiler report
input/code.cpp: In function 'void bfs(int)': input/code.cpp:32:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 32 | for(int j=0;j<e[u].size();j++) | ~^~~~~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; const int N=2509; int n,m,q; int ans[N][N][2]; bool vst[N][2]; vector<int>e[N]; struct Node{ int u,p; }; void bfs(int i){ memset (vst, 0,sizeof(vst)); queue<Node>q; ans[i][i][0]=0; vst[i][0]=1; q.push({i,0}); while(!q.empty()){ Node now=q.front(); int u=now.u; int p=now.p; q.pop(); for(int j=0;j<e[u].size();j++) if(!vst[e[u][j]][(p&1)^1]){ int v=e[u][j]; vst[v][(p&1)^1]=1; ans[i][v][(p&1)^1]=p+1; q.push({v,p+1}); } } } void query(){ while(q--){ int a,b,x; cin>>a>>b>>x; cout<<(ans[a][b][x&1]<=x?"YES":"NO")<<"\n"; } } int main(){ memset(ans,0x3f,sizeof(ans)); cin>>n>>m>>q; for(int i=1;i<=m;i++){ int u,v; cin>>u>>v; e[u].push_back(v); e[v].push_back(u); } for(int i=1;i<=n;i++){ bfs(i); } query(); return 0; }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
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 NO YES NO ... Truncated |
Test 2
Group: 1, 2
Verdict: ACCEPTED
input |
---|
50 49 100 33 34 7 8 49 50 47 48 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
NO NO NO NO NO ... Truncated |
Test 3
Group: 2
Verdict: ACCEPTED
input |
---|
2500 2499 100000 821 822 2351 2352 752 753 832 833 ... |
correct output |
---|
NO YES YES NO NO ... |
user output |
---|
NO YES YES NO NO ... Truncated |
Test 4
Group: 1, 2
Verdict: ACCEPTED
input |
---|
12 12 100 9 10 2 3 1 12 1 2 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
NO NO NO NO NO ... Truncated |
Test 5
Group: 1, 2
Verdict: ACCEPTED
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: ACCEPTED
input |
---|
2500 2500 100000 1936 1937 1884 1885 751 752 831 832 ... |
correct output |
---|
NO YES YES NO NO ... |
user output |
---|
NO YES YES NO NO ... Truncated |
Test 7
Group: 2
Verdict: ACCEPTED
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: ACCEPTED
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: ACCEPTED
input |
---|
2500 4999 100000 1191 2361 251 399 1026 2300 82 1655 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... Truncated |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
2500 4999 100000 2023 2218 23 51 1020 1272 11 114 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... Truncated |