# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
287994 |
2020-09-01T07:40:11 Z |
최은수(#5768) |
JOIRIS (JOI16_joiris) |
C++17 |
|
1 ms |
388 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
vector<int>v;
vector<pi>qv;
int n;
inline void rev()
{
for(int i=0;i++<n;)
{
if(v[i]==0)
qv.eb(1,i),v[i]=1;
else
v[i]=0;
}
return;
}
inline bool zero()
{
for(int i=0;i++<n;)
if(v[i]!=v[1])
return 0;
return 1;
}
inline void process()
{
for(int i=n;i-->1;)
{
if(v[i]==0&&v[i+1]==0)
{
qv.eb(2,i);
v[i]=1,v[i+1]=1;
}
}
for(int i=n;i-->1;)
{
if(v[i]==1&&v[i+1]==0)
{
qv.eb(2,i);
for(int j=0;j++<n;)
if(i!=j)
qv.eb(1,j);
v[i]=0,v[i+1]=1;
break;
}
}
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int k;
cin>>n>>k;
v.resize(n);
for(int&t:v)
cin>>t;
v.insert(v.begin(),0);
int c=0;
for(int i=0;i++<n;)
{
for(int j=v[i]/2;j<30;j++)
qv.eb(1,i);
v[i]%=2;
c+=v[i];
}
if(n%2==0&&c%2==1)
return cout<<-1<<endl,0;
if(n%2==1&&c%2==0)
rev();
while(!zero())
process();
cout<<qv.size()<<endl;
for(pi&t:qv)
cout<<t.fi<<' '<<t.se<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
388 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |