# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
38144 |
2018-01-02T05:05:31 Z |
funcsr |
JOIRIS (JOI16_joiris) |
C++14 |
|
0 ms |
2016 KB |
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <cassert>
#include <algorithm>
#define rep(i,n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define _1 first
#define _2 second
using namespace std;
typedef pair<int, int> P;
int N, K;
int A[50];
vector<P> ans;
void update() {
int lo = *min_element(A, A+N);
rep(i, N) A[i] -= lo;
}
void tate(int x) {
A[x] += 2;
update();
ans.pb(P(1, x));
}
void yoko(int x) {
A[x] += 1;
A[x+1] += 1;
update();
ans.pb(P(2, x));
}
void solve() {
int lo = *min_element(A, A+N), hi = *max_element(A, A+N);
if (hi-lo > 1) {
rep(i, N) if (A[i] == lo) tate(i);
return;
}
vector<int> zero;
rep(i, N) if (A[i] == 0) zero.pb(i);
rep(i, (int)zero.size()-1) {
int a = zero[i], b = zero[i+1];
if ((b-a)%2 == 1) {
for (int x=a; x<b; x+=2) yoko(x);
return;
}
}
int a = zero[0], b = zero[1];
tate(a);
for (int i=a+1; i<N-1; i+=2) yoko(i);
}
int main() {
cin >> N >> K;
if (K != 2) abort();
int sum = 0;
rep(i, N) cin >> A[i], sum += A[i];
if (N % 2) abort();
if (sum % 2) {
cout << -1 << "\n";
return 0;
}
while (*max_element(A, A+N) > 0) {
solve();
}
cout << ans.size() << "\n";
for (P p : ans) {
cout << p._1 << " " << p._2 << "\n";
}
return 0;
}
Compilation message
joiris.cpp: In function 'void solve()':
joiris.cpp:49:20: warning: unused variable 'b' [-Wunused-variable]
int a = zero[0], b = zero[1];
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2016 KB |
Output is correct |
2 |
Correct |
0 ms |
2016 KB |
Output is correct |
3 |
Correct |
0 ms |
2016 KB |
Output is correct |
4 |
Incorrect |
0 ms |
2016 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
2016 KB |
Execution killed because of forbidden syscall gettid (186) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2016 KB |
Output is correct |
2 |
Correct |
0 ms |
2016 KB |
Output is correct |
3 |
Correct |
0 ms |
2016 KB |
Output is correct |
4 |
Incorrect |
0 ms |
2016 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2016 KB |
Output is correct |
2 |
Correct |
0 ms |
2016 KB |
Output is correct |
3 |
Correct |
0 ms |
2016 KB |
Output is correct |
4 |
Incorrect |
0 ms |
2016 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |