#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
#define pii pair <int,int>
#define all(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
using namespace std;
const int N=4;
int a[N],b[N];
vector <pii> ans,prt[2];
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
while(a[i]<N){
a[i]+=2;
ans.pb({1,i});
}
}
int j=1,res0=1,res1=1;
for(int i=1;i<=n;i=j){
while(j<=n && a[i]%2==a[j]%2) j++;
for(int k=i;k<j;k+=2){
prt[a[i]%2].pb({2,k});
}
if((j-i)%2){
if(a[i]%2) res1=0;
else res0=0;
}
}
if(res0){
cout<<SZ(ans)+SZ(prt[0])<<endl;
for(pii p:ans) cout<<p.F<<" "<<p.S<<endl;
for(pii p:prt[0]) cout<<p.F<<" "<<p.S<<endl;
}
else if(res1){
cout<<SZ(ans)+n-SZ(prt[1])<<endl;
for(pii p:ans) cout<<p.F<<" "<<p.S<<endl;
for(int i=1;i<=n;i++) if(a[i]%2==0) cout<<1<<" "<<i<<endl;
for(pii p:prt[1]) cout<<p.F<<" "<<p.S<<endl;
}
else cout<<-1<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |