# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1166381 | nhphuc | JOIRIS (JOI16_joiris) | C++20 | 1 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 57;
int n, k, a[N];
vector<pair<int, int>> ans;
void add_ver (int i){
a[i] += k;
ans.push_back({1, i});
return;
}
void add_hor (int i){
for (int j = i; j <= i + k - 1; ++j){
a[j] += 1;
}
ans.push_back({2, i});
return;
}
void upd (int i){
int mx = *max_element(a + i, a + i + k) + k;
for (int j = 1; j < i; ++j){
while (a[j] < mx){
add_ver(j);
}
}
for (int j = i + k; j <= n; ++j){
while (a[j] < mx){
add_ver(j);
}
}
add_hor(i);
return;
}
int32_t main (){
ios::sync_with_stdio(false); cin.tie(nullptr);
if (fopen ("test.inp", "r")){
freopen ("test.inp", "r", stdin);
freopen ("test.out", "w", stdout);
}
cin >> n >> k;
for (int i = 1; i <= n; ++i){
cin >> a[i];
}
for (int i = 1; i <= n - k + 1; ++i){
while (abs(a[i] - a[1]) % k != 0){
upd(i);
}
}
for (int i = n - k + 1; i >= 1; --i){
while (abs(a[i + k - 1] - a[n]) % k != 0){
upd(i);
}
}
int mx = *max_element(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i){
while (a[i] < mx){
add_ver(i);
}
if (a[i] != mx){
return cout << -1, 0;
}
}
cout << ans.size() << "\n";
for (auto [x, y] : ans){
cout << x << " " << y << "\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |