Submission #287965

# Submission time Handle Problem Language Result Execution time Memory
287965 2020-09-01T07:15:57 Z 임성재(#5782) JOIRIS (JOI16_joiris) C++17
30 / 100
3 ms 556 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
const ll Mod = 1e9 + 7;

int n, k;
int a[55];
vector<pii> ans;

bool chk() {
	//for(int i=1; i<=n; i++)
		//cout << a[i] << " ";

	//cout << endl;

	for(int i=2; i<=n; i++) {
		if(a[i] != a[1]) return true;
	}

	return false;
}

void qr(int tmp, int x) {
	if(tmp == 1) {
		a[x] += k;
	}
	else {
		for(int i=x; i<x + k; i++)
			a[i]++;
	}

	ans.eb(tmp, x);

	if(ans.size() > 10000) {
		cout << -1;
		exit(0);
	}

	if(!chk()) {
		cout << ans.size() << "\n";

		for(auto i : ans) {
			cout << i.fi << " " << i.se << "\n";
		}

		exit(0);
	}
}

void f() {
	for(int i=n-1; i>=1; i--) {
		while(a[i] <= a[i+1]-2) {
			qr(1, i);
		}
	}
}

int main() {
	fast;

	cin >> n >> k;

	for(int i=1; i<=n; i++) {
		cin >> a[i];
	}

	for(int i=2; i<=n; i++) {
		while(a[i-1] > a[i]) {
			qr(1, i);
		}
	}

	f();

	int cnt = 0;
	int p = -1;

	while((int) ans.size() > p) {
		p = ans.size();

		int cur = 1;
		for(int i=1; i<=n; i++) {
			if(i < n && a[i] == a[i+1]) continue;

			for(int j=i; cur <= j-k+1; j-=k) {
				qr(2, j-k+1);
			}

			if(ans.size()) cur = ans.back().se;
			if(a[cur] != a[i]) cur = i;
		}

		if(k < n && a[k] != a[k+1]) {
			qr(2, 1);
		}

		f();
	}

	cout << -1;
}

Compilation message

joiris.cpp: In function 'int main()':
joiris.cpp:88:6: warning: unused variable 'cnt' [-Wunused-variable]
   88 |  int cnt = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 556 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 388 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 556 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Incorrect 3 ms 512 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 556 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 388 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 3 ms 512 KB Output is correct
35 Incorrect 3 ms 512 KB Output isn't correct
36 Halted 0 ms 0 KB -