# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45372 | model_code | Binary Subsequences (info1cup17_binary) | C++17 | 896 ms | 692 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int Tests, ans[1000009];
void solve (int K)
{
int cnt = 0, minL = K + 2, how = -1;
for (int T = 0; T <= K - T; T++)
{
int i = T, j = K - T, currL = 0;
bool fail = 0;
while (i > 0 || j > 0)
{
if (i < 0 || j < 0)
{
fail = 1;
break;
}
if (i < j) swap (i, j);
int curr = (i - j - 1) / (j + 1) + 1;
i -= curr * (j + 1), currL += curr;
}
if (!fail)
{
cnt ++;
if (T != K - T) cnt ++;
if (currL < minL)
minL = currL, how = T;
}
}
printf ("%d\n", cnt), ans[0] = 0;
int i = how, j = K - how;
while (i > 0 || j > 0)
{
if (i > j) i = i - j - 1, ans[++ans[0]] = 1;
else j = j - i - 1, ans[++ans[0]] = 0;
}
for (int i=ans[0]; i>=1; i--)
printf ("%d ", ans[i]);
printf ("\n");
}
int main ()
{
scanf ("%d", &Tests);
for (int i=1; i<=Tests; i++)
{
int x;
scanf ("%d", &x);
solve (x);
}
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... |