답안 #122954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122954 2019-06-29T16:09:40 Z egorlifar JOIRIS (JOI16_joiris) C++17
0 / 100
3 ms 764 KB
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
    
     
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } 
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
const string FILENAME = "input";



int n, k;
int a[51];
	vector<pair<int, int> > res;

void dof() {
	vector<int> st;
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			st.pb(i);
		}
	}
	for (auto x: st) {
		a[x] += k;
		res.pb({1, x + 1});
	}
	int t = 1e9;
	for (int i = 0; i < n; i++) {
		chkmin(t, a[i]);
	}
	for (int i = 0; i < n; i++) {
		a[i] -= t;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//read(FILENAME);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	while (true) {
		bool was = false;
		for (int i = 0; i < n; i++) {
			if (abs(a[i]) > 1) {
				was = true;
			}
		}
		if (!was) {
			break;
		}
		dof();
	}
	for (int g = 0; g < 1000; g++) {
		bool was = false;
		for (int i = 0; i < n; i++) {
			if (a[i]) {
				was = true;
			}
		}
		if (!was) {
			cout << sz(res) << endl;
			for (auto x: res) {
				cout << x.first << ' ' << x.second << '\n';
			}
			return 0;
		}
		for (int i =0; i < n - 1; i++) {
			if (a[i] == 0 && a[i + 1] == 0) {
				a[i]++;
				a[i + 1]++;
				res.pb({2, i + 1});
			}
		}
		bool kek = false;
		for (int i =0; i < n; i++) {
			if (!a[i]) {
				kek = true;
				break;
			}
		}
		if (!kek) {
			break;
		}
		// while (!res.empty() && res.back().first == 2) {
		// 	int x = res.back().second;
		// 	a[x]--;
		// 	a[x - 1]--;
		// 	res.pop_back();
		// }
		dof();
		if (g == 999) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << sz(res) << endl;
	for (auto x: res) {
		cout << x.first << ' ' << x.second << '\n';
	}
	return 0; 		
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 764 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Incorrect 2 ms 504 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 764 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Incorrect 2 ms 504 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 764 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Incorrect 2 ms 504 KB Output isn't correct
14 Halted 0 ms 0 KB -