Task: | Peli |
Sender: | a256 |
Submission time: | 2024-01-20 15:47:58 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 42 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 42 |
#2 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.11 s | 1, 2 | details |
#3 | RUNTIME ERROR | 0.00 s | 2 | details |
#4 | ACCEPTED | 0.01 s | 1, 2 | details |
#5 | ACCEPTED | 0.01 s | 1, 2 | details |
#6 | RUNTIME ERROR | 0.00 s | 2 | details |
#7 | RUNTIME ERROR | 0.00 s | 2 | details |
#8 | ACCEPTED | 0.11 s | 1, 2 | details |
#9 | RUNTIME ERROR | 0.00 s | 2 | details |
#10 | RUNTIME ERROR | 0.00 s | 2 | details |
Code
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define N 100 #define MTR array<array<int,N>,N> int n,m,q,x,a,b; MTR DOT(MTR A,MTR B){ MTR T; for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ T[i][j]=0; } } for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ for(int k=0;k<n;++k){ T[i][j]+=A[i][k]*B[k][j]; } if(T[i][j]>0) T[i][j]=1; } } return T; } MTR POT(MTR B,int e){ MTR A; for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ A[i][j]=0; } } for(int i=0;i<n;++i) A[i][i]=1; while(e){ if(e&1) A=DOT(A,B); e/=2; B=DOT(B,B); } return A; } int main(){ cin>>n>>m>>q; MTR V; for(int i=0;i<m;++i){ cin>>a>>b; --a;--b; V[a][b]=1; V[b][a]=1; } for(int i=0;i<q;++i){ cin>>a>>b>>x;--a;--b; MTR R=POT(V,x); if(R[a][b]==0){ cout<<"NO\n"; } else { cout<<"YES\n"; } } }
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: RUNTIME ERROR
input |
---|
2500 2499 100000 821 822 2351 2352 752 753 832 833 ... |
correct output |
---|
NO YES YES NO NO ... |
user output |
---|
(empty) |
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: RUNTIME ERROR
input |
---|
2500 2500 100000 1936 1937 1884 1885 751 752 831 832 ... |
correct output |
---|
NO YES YES NO NO ... |
user output |
---|
(empty) |
Test 7
Group: 2
Verdict: RUNTIME ERROR
input |
---|
2499 2499 100000 821 822 2351 2352 752 753 832 833 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
(empty) |
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: RUNTIME ERROR
input |
---|
2500 4999 100000 1191 2361 251 399 1026 2300 82 1655 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
(empty) |
Test 10
Group: 2
Verdict: RUNTIME ERROR
input |
---|
2500 4999 100000 2023 2218 23 51 1020 1272 11 114 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
(empty) |