Task: | Tietoverkko |
Sender: | Leiska |
Submission time: | 2018-01-18 15:51:44 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.19 s | 1 | details |
#2 | RUNTIME ERROR | 0.23 s | 1 | details |
#3 | RUNTIME ERROR | 0.23 s | 1 | details |
#4 | RUNTIME ERROR | 0.20 s | 1 | details |
#5 | ACCEPTED | 0.05 s | 1 | details |
#6 | TIME LIMIT EXCEEDED | -- | 2 | details |
#7 | TIME LIMIT EXCEEDED | -- | 2 | details |
#8 | TIME LIMIT EXCEEDED | -- | 2 | details |
#9 | TIME LIMIT EXCEEDED | -- | 2 | details |
#10 | ACCEPTED | 0.08 s | 2 | details |
Compiler report
input/code.cpp: In function 'int findv(int)': input/code.cpp:11:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<v.size(); i++) { ^
Code
#include <bits/stdc++.h> using namespace std; int n; int p = 0; vector<int> v; vector<int> w; int findv(int x) { for(int i=0; i<v.size(); i++) { if(v[i]==x) { return i; } } return -1; } void removesingle() { int c = 0; for(int i = 0; i<n+1; i++) { if(w[i] == 1) { p++; int pos = findv(i); w[i]--; if(pos%2==0) { w[i+1]--; if(w[i+1] == 1) c = 1; v.erase(v.begin()+pos); v.erase(v.begin()+pos+1); } else { w[i-1]--; if(w[i-1] == 1) c = 1; v.erase(v.begin()+pos); v.erase(v.begin()+pos-1); } } } if(c==0) return; removesingle(); } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n; for(int i = 0; i<n+1; i++) w.push_back(0); for(int i = 0; i<(n*2); i++) { int t; cin >> t; v.push_back(t); w[t]++; } removesingle(); cout << p << endl; }
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 16 88 6 77 60 92 98 64 ... |
correct output |
---|
97 |
user output |
---|
(empty) |
Test 2
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 97 41 95 93 79 60 5 4 ... |
correct output |
---|
95 |
user output |
---|
53 |
Error:
*** Error in `input/code': munmap_chunk(): invalid pointer: 0x000000000150d300 ***
Test 3
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 87 24 21 49 86 85 42 32 ... |
correct output |
---|
90 |
user output |
---|
(empty) |
Test 4
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 30 24 54 79 51 6 80 29 ... |
correct output |
---|
50 |
user output |
---|
44 |
Error:
*** Error in `input/code': double free or corruption (out): 0x0000000001d52300 ***
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
100 11 27 54 59 100 90 2 95 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 6
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 98276 76171 70684 49183 48756 661 17166 16972 ... |
correct output |
---|
99997 |
user output |
---|
(empty) |
Test 7
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 35903 47275 13566 84 58018 42495 57071 4451 ... |
correct output |
---|
99995 |
user output |
---|
(empty) |
Test 8
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 79209 94485 60266 86793 27501 19927 13544 59730 ... |
correct output |
---|
99000 |
user output |
---|
(empty) |
Test 9
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 68402 82703 12892 46068 60013 40753 26168 34434 ... |
correct output |
---|
90000 |
user output |
---|
(empty) |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
100000 37330 74855 54324 45726 61652 15611 79081 47339 ... |
correct output |
---|
0 |
user output |
---|
0 |