Task: | Peli |
Sender: | Kemm1706 |
Submission time: | 2024-01-20 16:50:02 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 42 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 42 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2 | details |
#2 | ACCEPTED | 0.00 s | 1, 2 | details |
#3 | ACCEPTED | 0.21 s | 2 | details |
#4 | ACCEPTED | 0.00 s | 1, 2 | details |
#5 | ACCEPTED | 0.00 s | 1, 2 | details |
#6 | ACCEPTED | 0.23 s | 2 | details |
#7 | ACCEPTED | 0.27 s | 2 | details |
#8 | ACCEPTED | 0.00 s | 1, 2 | details |
#9 | WRONG ANSWER | 0.88 s | 2 | details |
#10 | ACCEPTED | 0.87 s | 2 | details |
Compiler report
input/code.cpp: In function 'void bfs(const vvl&, ll, std::vector<std::vector<std::vector<long long int> > >&, vl&, std::queue<std::pair<std::pair<long long int, long long int>, long long int> >)': input/code.cpp:53:34: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' 53 | auto [u, v] = xq.front(); | ^ input/code.cpp:21:17: warning: unused variable 'j' [-Wunused-variable] 21 | ll i, node, j; | ^ input/code.cpp: In function 'int main()': input/code.cpp:142:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' 142 | auto [u, v] = x.front(); | ^
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector <ll> vl; typedef vector <vl> vvl; typedef pair <ll, ll> pl; typedef vector <pl> vpl; typedef vector <bool> vb; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll nmax = 1e6; #define fi first #define se second #define mp make_pair #define pb push_back void bfs(const vvl &g, ll n, vector <vvl> &m, vl &parent, queue <pair <pl, ll>> xq) { ll i, node, j; queue <ll> q; q.push(1); while(!q.empty()) { node = q.front(); q.pop(); for(auto x : g[node]) { if(x != parent[node]) { parent[x] = node; //ll t = node; //while(x != 0) //{ bool change = false; for(i = 1; i <= n; i++) { if(m[0][node][i] != inf && m[1][x][i] > m[0][node][i] + 1) { m[1][x][i] = m[1][i][x] = m[0][node][i] + 1; change = true; } if(m[1][node][i] != inf && m[0][x][i] > m[1][node][i] + 1) { m[0][x][i] = m[0][i][x] = m[1][node][i] + 1; change = true; } while(!xq.empty()) { auto [u, v] = xq.front(); if(m[v % 2][u.fi][u.se] != inf) xq.pop(); else break; } if(xq.empty()) return; } if(change) q.push(x); else break; //node = x; //x = parent[x]; //} //node = t; } } } /*for(ll i = 1; i <= n; i++) { cerr << i << ": "; for(ll j = 1; j <= n; j++) cerr << m[0][i][j] << " "; cerr << "\n"; } cerr << "\n"; for(ll i = 1; i <= n; i++) { cerr << i << ": "; for(ll j = 1; j <= n; j++) cerr << m[1][i][j] << " "; cerr << "\n"; }*/ } /*4 5 6 1 2 2 3 1 3 2 4 3 4 1 2 2 1 4 1 1 4 5 2 2 1 2 2 2 3 4 8*/ int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n, t, q, i, a, b, k; pl ans; cin >> n >> t >> q; vvl g(n + 1); vpl minn(n + 1, {inf, inf}); vl parent(n + 1, 0); queue <pair <pl, ll>> x; vector <vvl> m(2, vvl(n + 1, vl(n + 1, inf))); for(i = 1; i <= n; i++) m[0][i][i] = 0; for(i = 0; i < t; i++) { cin >> a >> b; g[a].pb(b); g[b].pb(a); } //bfs(g, n, m, parent); //cerr << "\n"; while(q--) { cin >> a >> b >> k; x.push({{a, b}, k}); } bfs(g, n, m, parent, x); while(!x.empty()) { auto [u, v] = x.front(); x.pop(); //cerr << m[v % 2][u.fi][u.se] << " "; if(m[v % 2][u.fi][u.se] <= v) cout << "YES\n"; else cout << "NO\n"; } /*for(ll i = 1; i <= n; i++) { cerr << i << ": "; for(ll j = 1; j <= n; j++) cerr << m[0][i][j] << " "; cerr << "\n"; } cerr << "\n"; for(ll i = 1; i <= n; i++) { cerr << i << ": "; for(ll j = 1; j <= n; j++) cerr << m[1][i][j] << " "; cerr << "\n"; }*/ 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: 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 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 |