| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 332270 | IgorI | Devil's Share (RMI19_devil) | C++17 | 80 ms | 12072 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
string chk(string s, int k)
{
string mx = "";
for (int i = 0; i + k <= s.size(); i++)
mx = max(mx, s.substr(i, k));
return mx;
}
string solve(int c1, int c2)
{
if (c1 == 0)
{
return string(c2, '2');
}
if (c2 % c1 == 0)
{
string res = "";
for (int i = 0; i < c1; i++)
{
for (int j = 0; j < c2 / c1; j++)
res += "2";
res += "1";
}
return res;
}
vector<int> h(c1, c2 / c1);
string g = solve(c1 - c2 % c1, c2 % c1);
for (int i = 0; i < h.size(); i++)
{
if (g[i] == '2') h[i]++;
}
string res = "";
for (int i = 0; i < h.size(); i++)
{
for (int j = 0; j < h[i]; j++)
res += "2";
res += "1";
}
return res;
}
void solve()
{
int n = 10;
int k = 0;
cin >> k;
vector<int> d(n);
for (int i = 1; i < n; i++)
cin >> d[i];
if (0)
{
string f = string(d[1], '1') + string(d[2], '2');
string ans = f;
while (1)
{
if (chk(f, k) < chk(ans, k))
ans = f;
if (!next_permutation(f.begin(), f.end()))
break;
}
cout << ans << "\n";
cout << chk(ans, k) << "\n";
}
string ans = "";
if (d[1] == 0)
{
cout << string(d[2], '2') << "\n";
return;
}
string s(k - 1, '0');
for (int i = k - 2; i >= 0; i--)
{
if (d[2])
d[2]--, s[i] = '2';
else
d[1]--, s[i] = '1';
}
int c1 = d[1], c2 = d[2];
ans = solve(c1, c2) + s;
cout << ans << "\n";
//cout << k << "\n";
//cout << chk(ans, k) << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
}
컴파일 시 표준 에러 (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... | ||||
