제출 #204235

#제출 시각아이디문제언어결과실행 시간메모리
204235amoo_safarJOIRIS (JOI16_joiris)C++14
0 / 100
5 ms504 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " : " << x << '\n' using namespace std; typedef long long ll; const ll Mod = 1000000007LL; const int N = 2e5 + 10; const ll Inf = 2242545357980376863LL; const ll Log = 30; int n, k, a[N]; vector< pair<int, int> > V; void PlaceV(int x){ V.pb({1, x}); a[x] += k; } void PlaceH(int x){ V.pb({2, x}); for(int i = 0; i < k; i++) a[x + i] ++; } mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 2; i + k - 1 <= n; i++){ while((a[i - 1] % k) != (a[i] % k)){ PlaceH(i); } } for(int i = 2; i <= n; i++){ if((a[i - 1] % k) != (a[i] % k)) return cout << "-1\n", 0; } int mx = *max_element(a + 1, a + n + 1); shuffle(all(V), rng); for(int i = 1; i <= n; i++){ while(a[i] < mx) PlaceV(i); } int s = V.size(); for(int i = 0; i < ((s + k - 1) / k); i++){ for(int j = 1; j <= n; j++) PlaceV(j); } cout << V.size() << '\n'; for(auto x : V) cout << x.F << " " << x.S << '\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...