# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
332690 | daniel920712 | JOIRIS (JOI16_joiris) | C++14 | 419 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int all[55];
vector < pair < int , int > > ans;
int main()
{
int N,M,t=0,ok,small,i,st;
scanf("%d %d",&N,&M);
for(i=0;i<N;i++)
{
scanf("%d",&all[i]);
t+=all[i];
}
if(t%2==1)
{
printf("-1\n");
return 0;
}
else
{
while(1)
{
ok=1;
for(i=0;i<N;i+=2)
{
if(all[i]==0&&all[i+1]==1) break;
if(all[i]==1)
{
i=0;
break;
}
}
st=i;
for(i=i;i<N;i+=2)
{
if(all[i]==1||all[i+1]==0) ok=0;
}
if(ok)
{
//printf("%d\n",)
ans.push_back(make_pair(2,st+1));
all[st]++;
all[st+1]++;
for(i=st+2;i<N;i++)
{
all[i]+=2;
ans.push_back(make_pair(1,i+1));
}
all[st]++;
ans.push_back(make_pair(1,st+1));
for(i=0;i<st;i+=2)
{
ans.push_back(make_pair(2,i+1));
all[i]++;
all[i+1]++;
}
}
else
{
for(i=0;i<N;i++)
{
if(all[i]==0)
{
if(i+1<N&&all[i+1]==0)
{
ans.push_back(make_pair(2,i+1));
all[i]++;
all[i+1]++;
}
else
{
ans.push_back(make_pair(1,i+1));
all[i]+=2;
}
}
}
}
small=all[0];
for(i=0;i<N;i++) small=min(small,all[i]);
for(i=0;i<N;i++) all[i]-=small;
for(i=0;i<N;i++) if(all[i]) break;
if(i==N) break;
}
}
printf("%d\n",ans.size());
for(auto i:ans) printf("%d %d\n",i.first,i.second);
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... |