답안 #57155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57155 2018-07-14T07:23:10 Z 윤교준(#1654) JOIRIS (JOI16_joiris) C++11
30 / 100
3 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 <= N-L; i++) {
		for(; B[i] < B[N];) {
			Ans.eb(1, i);
			B[i] += L;
		}
	}

	for(; L < N && B[N] < B[1];) {
		Ans.eb(2, N-L+1);
		for(int i = N-L+1; i <= N; i++) B[i]++;
	}

	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 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
12 Correct 2 ms 560 KB Output is correct
13 Correct 2 ms 560 KB Output is correct
14 Correct 3 ms 560 KB Output is correct
15 Correct 2 ms 560 KB Output is correct
16 Correct 3 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
2 Incorrect 2 ms 628 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
12 Correct 2 ms 560 KB Output is correct
13 Correct 2 ms 560 KB Output is correct
14 Correct 3 ms 560 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 628 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 2 ms 636 KB Output is correct
20 Correct 2 ms 636 KB Output is correct
21 Correct 2 ms 636 KB Output is correct
22 Correct 2 ms 636 KB Output is correct
23 Correct 3 ms 652 KB Output is correct
24 Correct 2 ms 652 KB Output is correct
25 Correct 2 ms 652 KB Output is correct
26 Correct 3 ms 652 KB Output is correct
27 Correct 3 ms 668 KB Output is correct
28 Correct 2 ms 668 KB Output is correct
29 Correct 3 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 2 ms 668 KB Output is correct
34 Correct 2 ms 668 KB Output is correct
35 Correct 2 ms 668 KB Output is correct
36 Correct 2 ms 668 KB Output is correct
37 Correct 2 ms 668 KB Output is correct
38 Correct 2 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
12 Correct 2 ms 560 KB Output is correct
13 Correct 2 ms 560 KB Output is correct
14 Correct 3 ms 560 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 Incorrect 2 ms 628 KB Output isn't correct
19 Halted 0 ms 0 KB -