# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57190 |
2018-07-14T08:55:04 Z |
윤교준(#1654) |
JOIRIS (JOI16_joiris) |
C++11 |
|
4 ms |
964 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, K;
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();
K = N%L + 1;
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(K < L) {
int mx = *max_element(B+K, B+L);
for(int i = K+1; i < L; i++) {
for(; B[i] < mx;) {
Ans.eb(1, i);
B[i] += L;
}
}
}
if(1 < K) {
int mx = *max_element(B+1, B+K);
for(int i = 1; i < K; i++) {
for(; B[i] < mx;) {
Ans.eb(1, i);
B[i] += L;
}
}
for(int i = K; i+L-1 <= N; i += L) {
for(; B[i] < mx;) {
Ans.eb(2, i);
for(int j = i; j < i+L; j++)
B[j]++;
}
}
}
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
488 KB |
Output is correct |
8 |
Correct |
2 ms |
488 KB |
Output is correct |
9 |
Correct |
2 ms |
520 KB |
Output is correct |
10 |
Correct |
2 ms |
532 KB |
Output is correct |
11 |
Correct |
2 ms |
532 KB |
Output is correct |
12 |
Correct |
2 ms |
532 KB |
Output is correct |
13 |
Correct |
2 ms |
532 KB |
Output is correct |
14 |
Correct |
2 ms |
532 KB |
Output is correct |
15 |
Correct |
2 ms |
560 KB |
Output is correct |
16 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
620 KB |
Output is correct |
2 |
Correct |
3 ms |
620 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
3 ms |
620 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
3 ms |
636 KB |
Output is correct |
9 |
Correct |
3 ms |
636 KB |
Output is correct |
10 |
Correct |
3 ms |
636 KB |
Output is correct |
11 |
Correct |
3 ms |
636 KB |
Output is correct |
12 |
Correct |
3 ms |
652 KB |
Output is correct |
13 |
Correct |
3 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
652 KB |
Output is correct |
15 |
Correct |
3 ms |
652 KB |
Output is correct |
16 |
Correct |
2 ms |
652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
488 KB |
Output is correct |
8 |
Correct |
2 ms |
488 KB |
Output is correct |
9 |
Correct |
2 ms |
520 KB |
Output is correct |
10 |
Correct |
2 ms |
532 KB |
Output is correct |
11 |
Correct |
2 ms |
532 KB |
Output is correct |
12 |
Correct |
2 ms |
532 KB |
Output is correct |
13 |
Correct |
2 ms |
532 KB |
Output is correct |
14 |
Correct |
2 ms |
532 KB |
Output is correct |
15 |
Correct |
2 ms |
560 KB |
Output is correct |
16 |
Correct |
3 ms |
620 KB |
Output is correct |
17 |
Correct |
3 ms |
652 KB |
Output is correct |
18 |
Correct |
2 ms |
652 KB |
Output is correct |
19 |
Correct |
2 ms |
652 KB |
Output is correct |
20 |
Correct |
3 ms |
652 KB |
Output is correct |
21 |
Correct |
2 ms |
652 KB |
Output is correct |
22 |
Correct |
4 ms |
652 KB |
Output is correct |
23 |
Correct |
2 ms |
680 KB |
Output is correct |
24 |
Correct |
3 ms |
684 KB |
Output is correct |
25 |
Correct |
3 ms |
688 KB |
Output is correct |
26 |
Correct |
3 ms |
688 KB |
Output is correct |
27 |
Correct |
3 ms |
696 KB |
Output is correct |
28 |
Correct |
3 ms |
696 KB |
Output is correct |
29 |
Correct |
2 ms |
708 KB |
Output is correct |
30 |
Correct |
2 ms |
708 KB |
Output is correct |
31 |
Correct |
2 ms |
708 KB |
Output is correct |
32 |
Correct |
3 ms |
708 KB |
Output is correct |
33 |
Correct |
3 ms |
708 KB |
Output is correct |
34 |
Correct |
2 ms |
708 KB |
Output is correct |
35 |
Correct |
3 ms |
708 KB |
Output is correct |
36 |
Correct |
2 ms |
708 KB |
Output is correct |
37 |
Correct |
3 ms |
708 KB |
Output is correct |
38 |
Correct |
2 ms |
708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
488 KB |
Output is correct |
8 |
Correct |
2 ms |
488 KB |
Output is correct |
9 |
Correct |
2 ms |
520 KB |
Output is correct |
10 |
Correct |
2 ms |
532 KB |
Output is correct |
11 |
Correct |
2 ms |
532 KB |
Output is correct |
12 |
Correct |
2 ms |
532 KB |
Output is correct |
13 |
Correct |
2 ms |
532 KB |
Output is correct |
14 |
Correct |
2 ms |
532 KB |
Output is correct |
15 |
Correct |
2 ms |
560 KB |
Output is correct |
16 |
Correct |
3 ms |
620 KB |
Output is correct |
17 |
Correct |
2 ms |
620 KB |
Output is correct |
18 |
Correct |
3 ms |
620 KB |
Output is correct |
19 |
Correct |
3 ms |
620 KB |
Output is correct |
20 |
Correct |
2 ms |
620 KB |
Output is correct |
21 |
Correct |
3 ms |
620 KB |
Output is correct |
22 |
Correct |
2 ms |
636 KB |
Output is correct |
23 |
Correct |
2 ms |
636 KB |
Output is correct |
24 |
Correct |
3 ms |
636 KB |
Output is correct |
25 |
Correct |
3 ms |
636 KB |
Output is correct |
26 |
Correct |
3 ms |
636 KB |
Output is correct |
27 |
Correct |
3 ms |
636 KB |
Output is correct |
28 |
Correct |
3 ms |
652 KB |
Output is correct |
29 |
Correct |
3 ms |
652 KB |
Output is correct |
30 |
Correct |
2 ms |
652 KB |
Output is correct |
31 |
Correct |
3 ms |
652 KB |
Output is correct |
32 |
Correct |
2 ms |
652 KB |
Output is correct |
33 |
Correct |
3 ms |
652 KB |
Output is correct |
34 |
Correct |
2 ms |
652 KB |
Output is correct |
35 |
Correct |
2 ms |
652 KB |
Output is correct |
36 |
Correct |
3 ms |
652 KB |
Output is correct |
37 |
Correct |
2 ms |
652 KB |
Output is correct |
38 |
Correct |
4 ms |
652 KB |
Output is correct |
39 |
Correct |
2 ms |
680 KB |
Output is correct |
40 |
Correct |
3 ms |
684 KB |
Output is correct |
41 |
Correct |
3 ms |
688 KB |
Output is correct |
42 |
Correct |
3 ms |
688 KB |
Output is correct |
43 |
Correct |
3 ms |
696 KB |
Output is correct |
44 |
Correct |
3 ms |
696 KB |
Output is correct |
45 |
Correct |
2 ms |
708 KB |
Output is correct |
46 |
Correct |
2 ms |
708 KB |
Output is correct |
47 |
Correct |
2 ms |
708 KB |
Output is correct |
48 |
Correct |
3 ms |
708 KB |
Output is correct |
49 |
Correct |
3 ms |
708 KB |
Output is correct |
50 |
Correct |
2 ms |
708 KB |
Output is correct |
51 |
Correct |
3 ms |
708 KB |
Output is correct |
52 |
Correct |
2 ms |
708 KB |
Output is correct |
53 |
Correct |
3 ms |
708 KB |
Output is correct |
54 |
Correct |
2 ms |
708 KB |
Output is correct |
55 |
Correct |
3 ms |
708 KB |
Output is correct |
56 |
Correct |
3 ms |
708 KB |
Output is correct |
57 |
Correct |
3 ms |
708 KB |
Output is correct |
58 |
Correct |
2 ms |
708 KB |
Output is correct |
59 |
Correct |
0 ms |
708 KB |
Output is correct |
60 |
Correct |
2 ms |
708 KB |
Output is correct |
61 |
Correct |
2 ms |
708 KB |
Output is correct |
62 |
Correct |
3 ms |
788 KB |
Output is correct |
63 |
Correct |
3 ms |
788 KB |
Output is correct |
64 |
Correct |
2 ms |
788 KB |
Output is correct |
65 |
Correct |
2 ms |
800 KB |
Output is correct |
66 |
Correct |
3 ms |
800 KB |
Output is correct |
67 |
Correct |
2 ms |
800 KB |
Output is correct |
68 |
Correct |
2 ms |
800 KB |
Output is correct |
69 |
Correct |
4 ms |
816 KB |
Output is correct |
70 |
Correct |
3 ms |
820 KB |
Output is correct |
71 |
Correct |
4 ms |
824 KB |
Output is correct |
72 |
Correct |
3 ms |
824 KB |
Output is correct |
73 |
Correct |
3 ms |
824 KB |
Output is correct |
74 |
Correct |
3 ms |
836 KB |
Output is correct |
75 |
Correct |
2 ms |
960 KB |
Output is correct |
76 |
Correct |
2 ms |
964 KB |
Output is correct |
77 |
Correct |
2 ms |
964 KB |
Output is correct |
78 |
Correct |
3 ms |
964 KB |
Output is correct |
79 |
Correct |
2 ms |
964 KB |
Output is correct |
80 |
Correct |
2 ms |
964 KB |
Output is correct |
81 |
Correct |
3 ms |
964 KB |
Output is correct |
82 |
Correct |
3 ms |
964 KB |
Output is correct |
83 |
Correct |
2 ms |
964 KB |
Output is correct |
84 |
Correct |
3 ms |
964 KB |
Output is correct |
85 |
Correct |
3 ms |
964 KB |
Output is correct |
86 |
Correct |
3 ms |
964 KB |
Output is correct |
87 |
Correct |
2 ms |
964 KB |
Output is correct |
88 |
Correct |
4 ms |
964 KB |
Output is correct |
89 |
Correct |
3 ms |
964 KB |
Output is correct |
90 |
Correct |
2 ms |
964 KB |
Output is correct |
91 |
Correct |
3 ms |
964 KB |
Output is correct |
92 |
Correct |
3 ms |
964 KB |
Output is correct |