Submission #287926

# Submission time Handle Problem Language Result Execution time Memory
287926 2020-09-01T06:48:46 Z 임성재(#5782) JOIRIS (JOI16_joiris) C++17
15 / 100
4 ms 512 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=2; i<=n; i++) {
		if(a[i] != a[1]) return true;
	}

	return false;
}

void f() {
	for(int i=n-1; i>=1; i--) {
		while(a[i] <= a[i+1]-2) {
			a[i] += k;
			ans.eb(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]) {
			a[i] += k;
			ans.eb(1, i);
		}
	}

	f();

	int cnt = 0;
	int p = -1;

	while(chk() && ans.size() < 10000 && (int) ans.size() > p) {
		p = ans.size();
		for(int i=1; i+k<=n; i++) {
			if(a[i] == a[i+k-1] && a[i] < a[i+k]) {
				ans.eb(2, i);

				for(int j=i; j<i+k; j++)
					a[j]++;
			}
		}

		if(k < n && a[k] != a[k+1]) {
			ans.eb(2, 1);

			for(int i=k+1; i<=n; i++) a[i]--;
		}

		f();
	}

	if(ans.size() >= 10000 || chk()) {
		cout << -1;
		return 0;
	}

	cout << ans.size() << "\n";

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

Compilation message

joiris.cpp: In function 'int main()':
joiris.cpp:58:6: warning: unused variable 'cnt' [-Wunused-variable]
   58 |  int cnt = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 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 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 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 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 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 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 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
17 Correct 1 ms 384 KB Output is correct
18 Correct 4 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 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 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 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 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
17 Incorrect 1 ms 384 KB Output isn't correct
18 Halted 0 ms 0 KB -