Submission #122954

#TimeUsernameProblemLanguageResultExecution timeMemory
122954egorlifarJOIRIS (JOI16_joiris)C++17
0 / 100
3 ms764 KiB
/* ЗАПУСКАЕМ ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░▄▀▒▒▀▀▀▀▄ ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄ ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░▄▄▌▌▄▌▌░░░░░ */ #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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...