# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
67131 | ege_eksi | DEL13 (info1cup18_del13) | C++14 | 25 ms | 1628 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ");
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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |