# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
57148 | gs13105 | JOIRIS (JOI16_joiris) | C++17 | 4 ms | 1068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
using namespace std;
int arr[60];
int cur[60];
int tmp[60];
int cnt[60];
int main()
{
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
int n, l, i, j, k;
scanf("%d%d", &n, &l);
for(i = 1; i <= n; i++)
scanf("%d", &arr[i]);
for(i = 0; i < l; i++)
{
for(j = 1; j <= n; j++)
{
cur[j] = arr[j];
tmp[j] = (arr[j] + i) % l;
}
for(j = 1; j <= n - l + 1; j++)
{
cnt[j] = (l - tmp[j]) % l;
for(k = j; k < j + l; k++)
tmp[k] = (tmp[k] + cnt[j]) % l;
}
bool ok = 1;
for(j = 1; j <= n; j++)
{
if(tmp[j])
{
ok = 0;
break;
}
}
if(!ok)
continue;
vector<pair<int, int>> res;
for(j = 1; j <= n - l + 1; j++)
{
for(k = 0; k < cnt[j]; k++)
res.push_back({ 2, j });
int mx = 0;
for(k = j; k < j + l; k++)
mx = max(mx, cur[k]);
int mn = 1e9;
for(k = 1; k <= n; k++)
{
if(j <= k && k < j + l)
cur[k] += cnt[j];
else
{
while(cur[k] < mx + cnt[j])
{
res.push_back({ 1, k });
cur[k] += l;
}
}
mn = min(mn, cur[k]);
}
for(k = 1; k <= n; k++)
cur[k] -= mn;
}
int mx = 0;
for(j = 1; j <= n; j++)
mx = max(mx, cur[j]);
for(j = 1; j <= n; j++)
{
while(cur[j] < mx)
{
res.push_back({ 1, j });
cur[j] += l;
}
}
printf("%d\n", (int)res.size());
for(auto &p : res)
printf("%d %d\n", p.first, p.second);
return 0;
}
printf("-1\n");
return 0;
}
컴파일 시 표준 에러 (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... |