Task: | Distance Code |
Sender: | Matias Järvenpää |
Submission time: | 2019-03-06 12:00:51 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
#3 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#4 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#5 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#6 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#7 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#8 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#9 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#10 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#11 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#12 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#13 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#14 | WRONG ANSWER | 0.02 s | 2, 3 | details |
#15 | WRONG ANSWER | 0.02 s | 2, 3 | details |
#16 | RUNTIME ERROR | 0.02 s | 3 | details |
#17 | RUNTIME ERROR | 0.02 s | 3 | details |
#18 | RUNTIME ERROR | 0.02 s | 3 | details |
#19 | RUNTIME ERROR | 0.01 s | 3 | details |
#20 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
Compiler report
input/code.cpp: In function 'int64_t hae(int64_t, int64_t, int64_t, int64_t)': input/code.cpp:15:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int64_t i=0; i<v[index].size(); i++){ ~^~~~~~~~~~~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:41:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int64_t i2=0; i2<v[i].size(); i2++){ ~~^~~~~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; int64_t t,n; int64_t ta[100000]; vector<int64_t> v[501]; set<int64_t> v2[501]; set<pair<int64_t,int64_t>> s; int64_t hae(int64_t index, int64_t g, int64_t d, int64_t prev){ if(g == d){ return index; } for(int64_t i=0; i<v[index].size(); i++){ if(v[index][i] != prev){ int64_t temp = hae(v[index][i],g,d+1,index); if(temp != -1){ return temp; } } } return -1; } int main(){ cin >> t >> n; if(t == 2){ for(int64_t i=0; i<(n-1); i++){ cin >> ta[i]; } v[0].push_back(1); v[1].push_back(0); int64_t index = 1; for(int64_t i=(n-3); i>=0; i--){ int64_t next = hae(index,ta[i]-1,0,-1); v[index+1].push_back(next); v[next].push_back(index+1); } for(int64_t i=0; i<n; i++){ for(int64_t i2=0; i2<v[i].size(); i2++){ if((s.count({i,v[i][i2]}) == 0) && (s.count({v[i][i2],i}) == 0)){ cout << i+1 << " " << v[i][i2]+1 << "\n"; s.insert({v[i][i2],i}); s.insert({i,v[i][i2]}); } } } } else{ for(int64_t i=0; i<(n-1); i++){ int64_t a,b; cin >> a >> b; v2[a].insert(b); v2[b].insert(a); } for(int64_t i=0; i<(n-1); i++){ for(int64_t i2=0; i2<n; i2++){ if(v2[i2+1].size() == 1){ if(i == (n-2)){ cout << *v2[i2+1].begin() << " "; } v2[*v2[i2+1].begin()].erase(i2+1); v2[i2+1].erase(v2[i2+1].begin()); cout << i2+1 << " "; break; } } } cout << "\n"; } }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
1 2 2 1 |
correct output |
---|
(empty) |
user output |
---|
1 2 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
1 3 3 1 2 1 |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 4 3 2 2 1 4 1 |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 4 2 3 3 4 1 3 |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 |
Test 5
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 5 3 5 4 1 1 3 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 |
Test 6
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 5 3 2 3 4 5 1 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 |
Test 7
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 5 4 3 1 4 4 2 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 |
Test 8
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 9 3 8 9 2 9 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 |
Test 9
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 9 2 5 8 7 1 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 3 3 |
Test 10
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 10 4 9 1 4 7 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 3 3 |
Test 11
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 2 6 4 3 3 5 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 |
Test 12
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 10 6 6 255 6 428 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 |
Test 13
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 152 466 451 313 158 479 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 3 3 |
Test 14
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 109 440 330 190 443 161 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 3 3 |
Test 15
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 144 373 257 233 341 318 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 3 3 |
Test 16
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1 100000 54983 75172 93807 75172 44082 75172 ... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 17
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1 100000 88863 19059 86423 76688 98536 95984 ... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 18
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1 100000 59979 6389 19097 24999 27846 82330 ... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 19
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1 100000 58761 66001 25102 51081 98625 67861 ... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 20
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 6 2 1 3 2 4 2 ... |
correct output |
---|
(empty) |
user output |
---|
1 2 1 3 2 3 |