# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
57161 |
2018-07-14T07:32:07 Z |
윤교준(#1654) |
JOIRIS (JOI16_joiris) |
C++11 |
|
4 ms |
668 KB |
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void fuk() { puts("-1"); exit(0); }
vector<pii> Ans;
int S[55];
int A[55], B[55];
int N, L;
int main() {
cin >> N >> L;
for(int i = 1; i <= N; i++) cin >> A[i];
for(int i = 0; i < N; i++) S[i%L] += A[i+1];
for(int i = 0; i < L; i++) S[i] %= L;
for(int i = 0; i < N%L; i++) if(S[0] != S[i]) fuk();
for(int i = N%L; i < L; i++) if(S[i] != S[L-1]) fuk();
for(int i = 2; i <= N; i++) {
for(; A[i] < A[i-1];) {
Ans.eb(1, i);
A[i] += L;
}
}
for(int i = 1; i <= N; i++) B[i] = A[i];
for(int h = 1; h <= A[N]; h++) {
int i = N; for(; i && h <= A[i]; i--);
for(i = i+1 - L; 1 <= i; i -= L) {
Ans.eb(2, i);
for(int j = i; j < i+L; j++) B[j]++;
}
}
for(int i = 1; i < L; i++) {
for(; B[i] < B[N];) {
Ans.eb(1, i);
B[i] += L;
}
}
if(L < N) {
int i = L;
for(; i+L-1 <= N; i += L) {
for(; B[i] < B[1];) {
Ans.eb(2, i);
for(int j = i; j < i+L; j++)
B[j]++;
}
}
for(; i <= N; i++) {
for(; B[i] < B[1];) {
Ans.eb(1, i);
B[i] += L;
}
}
}
for(int i = 2; i <= N; i++)
if(B[1] != B[i]) fuk();
printf("%d\n", sz(Ans));
for(auto &e : Ans) printf("%d %d\n", e.first, e.second);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
480 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
480 KB |
Output is correct |
8 |
Correct |
3 ms |
480 KB |
Output is correct |
9 |
Correct |
2 ms |
528 KB |
Output is correct |
10 |
Correct |
3 ms |
544 KB |
Output is correct |
11 |
Correct |
3 ms |
544 KB |
Output is correct |
12 |
Correct |
2 ms |
544 KB |
Output is correct |
13 |
Correct |
3 ms |
544 KB |
Output is correct |
14 |
Correct |
2 ms |
544 KB |
Output is correct |
15 |
Correct |
2 ms |
544 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
620 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
652 KB |
Output is correct |
7 |
Correct |
2 ms |
652 KB |
Output is correct |
8 |
Correct |
3 ms |
652 KB |
Output is correct |
9 |
Correct |
3 ms |
652 KB |
Output is correct |
10 |
Correct |
2 ms |
652 KB |
Output is correct |
11 |
Correct |
3 ms |
652 KB |
Output is correct |
12 |
Correct |
2 ms |
652 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
3 ms |
652 KB |
Output is correct |
15 |
Correct |
2 ms |
652 KB |
Output is correct |
16 |
Correct |
2 ms |
652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
480 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
480 KB |
Output is correct |
8 |
Correct |
3 ms |
480 KB |
Output is correct |
9 |
Correct |
2 ms |
528 KB |
Output is correct |
10 |
Correct |
3 ms |
544 KB |
Output is correct |
11 |
Correct |
3 ms |
544 KB |
Output is correct |
12 |
Correct |
2 ms |
544 KB |
Output is correct |
13 |
Correct |
3 ms |
544 KB |
Output is correct |
14 |
Correct |
2 ms |
544 KB |
Output is correct |
15 |
Correct |
2 ms |
544 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
17 |
Correct |
2 ms |
652 KB |
Output is correct |
18 |
Correct |
3 ms |
652 KB |
Output is correct |
19 |
Correct |
2 ms |
652 KB |
Output is correct |
20 |
Correct |
2 ms |
652 KB |
Output is correct |
21 |
Correct |
2 ms |
652 KB |
Output is correct |
22 |
Correct |
2 ms |
652 KB |
Output is correct |
23 |
Correct |
3 ms |
652 KB |
Output is correct |
24 |
Correct |
2 ms |
652 KB |
Output is correct |
25 |
Correct |
3 ms |
652 KB |
Output is correct |
26 |
Correct |
3 ms |
652 KB |
Output is correct |
27 |
Correct |
3 ms |
652 KB |
Output is correct |
28 |
Correct |
2 ms |
652 KB |
Output is correct |
29 |
Correct |
2 ms |
668 KB |
Output is correct |
30 |
Correct |
2 ms |
668 KB |
Output is correct |
31 |
Correct |
2 ms |
668 KB |
Output is correct |
32 |
Correct |
3 ms |
668 KB |
Output is correct |
33 |
Correct |
3 ms |
668 KB |
Output is correct |
34 |
Correct |
3 ms |
668 KB |
Output is correct |
35 |
Correct |
3 ms |
668 KB |
Output is correct |
36 |
Correct |
2 ms |
668 KB |
Output is correct |
37 |
Correct |
3 ms |
668 KB |
Output is correct |
38 |
Correct |
3 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
480 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
2 ms |
480 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
480 KB |
Output is correct |
8 |
Correct |
3 ms |
480 KB |
Output is correct |
9 |
Correct |
2 ms |
528 KB |
Output is correct |
10 |
Correct |
3 ms |
544 KB |
Output is correct |
11 |
Correct |
3 ms |
544 KB |
Output is correct |
12 |
Correct |
2 ms |
544 KB |
Output is correct |
13 |
Correct |
3 ms |
544 KB |
Output is correct |
14 |
Correct |
2 ms |
544 KB |
Output is correct |
15 |
Correct |
2 ms |
544 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
17 |
Correct |
2 ms |
620 KB |
Output is correct |
18 |
Correct |
2 ms |
620 KB |
Output is correct |
19 |
Correct |
3 ms |
620 KB |
Output is correct |
20 |
Correct |
3 ms |
620 KB |
Output is correct |
21 |
Correct |
2 ms |
620 KB |
Output is correct |
22 |
Correct |
4 ms |
652 KB |
Output is correct |
23 |
Correct |
2 ms |
652 KB |
Output is correct |
24 |
Correct |
3 ms |
652 KB |
Output is correct |
25 |
Correct |
3 ms |
652 KB |
Output is correct |
26 |
Correct |
2 ms |
652 KB |
Output is correct |
27 |
Correct |
3 ms |
652 KB |
Output is correct |
28 |
Correct |
2 ms |
652 KB |
Output is correct |
29 |
Correct |
2 ms |
652 KB |
Output is correct |
30 |
Correct |
3 ms |
652 KB |
Output is correct |
31 |
Correct |
2 ms |
652 KB |
Output is correct |
32 |
Correct |
2 ms |
652 KB |
Output is correct |
33 |
Correct |
2 ms |
652 KB |
Output is correct |
34 |
Correct |
3 ms |
652 KB |
Output is correct |
35 |
Correct |
2 ms |
652 KB |
Output is correct |
36 |
Correct |
2 ms |
652 KB |
Output is correct |
37 |
Correct |
2 ms |
652 KB |
Output is correct |
38 |
Correct |
2 ms |
652 KB |
Output is correct |
39 |
Correct |
3 ms |
652 KB |
Output is correct |
40 |
Correct |
2 ms |
652 KB |
Output is correct |
41 |
Correct |
3 ms |
652 KB |
Output is correct |
42 |
Correct |
3 ms |
652 KB |
Output is correct |
43 |
Correct |
3 ms |
652 KB |
Output is correct |
44 |
Correct |
2 ms |
652 KB |
Output is correct |
45 |
Correct |
2 ms |
668 KB |
Output is correct |
46 |
Correct |
2 ms |
668 KB |
Output is correct |
47 |
Correct |
2 ms |
668 KB |
Output is correct |
48 |
Correct |
3 ms |
668 KB |
Output is correct |
49 |
Correct |
3 ms |
668 KB |
Output is correct |
50 |
Correct |
3 ms |
668 KB |
Output is correct |
51 |
Correct |
3 ms |
668 KB |
Output is correct |
52 |
Correct |
2 ms |
668 KB |
Output is correct |
53 |
Correct |
3 ms |
668 KB |
Output is correct |
54 |
Correct |
3 ms |
668 KB |
Output is correct |
55 |
Correct |
3 ms |
668 KB |
Output is correct |
56 |
Correct |
3 ms |
668 KB |
Output is correct |
57 |
Incorrect |
2 ms |
668 KB |
Output isn't correct |
58 |
Halted |
0 ms |
0 KB |
- |