# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67130 | 2018-08-13T11:12:34 Z | ege_eksi | DEL13 (info1cup18_del13) | C++14 | 27 ms | 1580 KB |
#include<iostream> #include<cstdio> #include<cstdlib> #include<climits> #include<algorithm> #include<queue> #include<vector> #include<list> using namespace std; struct node { int start , end; int dist; }; class mycomparison { public: bool operator() (const node a, const node b) const { if(a.dist > b.dist) { return 0; } else if(a.dist < b.dist) { return 1; } else if(a.start < b.start) { return 0; } else { return 1; } } }; priority_queue< node , vector<node> , mycomparison > pq; int n , q; int a[100001]; list<int> moves; void func() { while(!pq.empty()) { pq.pop(); } moves.clear(); node x; x.start = 0; x.end = a[0]; x.dist = x.end - x.start - 1; pq.push(x); for(int i = 1 ; i < q ; i++) { x.start = a[i-1]; x.end = a[i]; x.dist = x.end - x.start - 1; pq.push(x); } x.start = a[q-1]; x.end = n+1; x.dist = x.end - x.start - 1; pq.push(x); node y; while(!pq.empty()) { x = pq.top(); pq.pop(); if(x.dist == 0) { break; } else if(x.dist > 2) { x.dist -= 2; pq.push(x); } else if(x.dist == 1) { if(!pq.empty() && pq.top().dist == 1) { y = pq.top(); pq.pop(); x.dist = 0; y.dist = 0; pq.push(x); pq.push(y); } else { printf("-1\n"); return; } } else { if(!pq.empty() && pq.top().dist == 2) { y = pq.top(); pq.pop(); x.dist = 1; y.dist = 1; pq.push(x); pq.push(y); } else { printf("-1"); return; } } } printf("0\n"); } int main() { int t; scanf("%d" , &t); while(t--) { scanf("%d %d",&n,&q); for(int i = 0 ; i < q ; i++) { scanf("%d" , &a[i]); } func(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Incorrect | 3 ms | 376 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Incorrect | 3 ms | 376 KB | Output isn't correct |
3 | Incorrect | 7 ms | 500 KB | Expected integer, but "-1-1-10" found |
4 | Incorrect | 6 ms | 504 KB | Expected integer, but "-1-1-10" found |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 696 KB | Expected integer, but "-1-1" found |
2 | Incorrect | 11 ms | 696 KB | Expected integer, but "-1-1" found |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Incorrect | 3 ms | 376 KB | Output isn't correct |
3 | Incorrect | 7 ms | 500 KB | Expected integer, but "-1-1-10" found |
4 | Incorrect | 6 ms | 504 KB | Expected integer, but "-1-1-10" found |
5 | Incorrect | 3 ms | 696 KB | Output isn't correct |
6 | Incorrect | 3 ms | 696 KB | Output isn't correct |
7 | Incorrect | 3 ms | 696 KB | Expected integer, but "-1-10" found |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Incorrect | 3 ms | 376 KB | Output isn't correct |
3 | Incorrect | 7 ms | 500 KB | Expected integer, but "-1-1-10" found |
4 | Incorrect | 6 ms | 504 KB | Expected integer, but "-1-1-10" found |
5 | Incorrect | 3 ms | 696 KB | Output isn't correct |
6 | Incorrect | 3 ms | 696 KB | Output isn't correct |
7 | Incorrect | 3 ms | 696 KB | Expected integer, but "-1-10" found |
8 | Incorrect | 20 ms | 696 KB | Output isn't correct |
9 | Incorrect | 27 ms | 1136 KB | Output isn't correct |
10 | Incorrect | 23 ms | 1204 KB | Output isn't correct |
11 | Incorrect | 25 ms | 1580 KB | Expected integer, but "-1-1-10" found |