이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int t, k;
void pro(int k){
    int cnt = 0;
    int len = INT_MAX, lenx = 0;
    for(int i = 0; i + i < k; i++){
        int x = i, y = k - x;
        int nlen = 0;
        while(x){
            if(x == y){
                nlen = INT_MAX;
                break;
            }
            nlen += y / (x+1);
            y %= (x+1);
            swap(x,y);
        }
        if(nlen < INT_MAX) cnt += 2, nlen += y;
        if(nlen < len){
            len = nlen;
            lenx = i;
        }
    }
    cout << cnt << '\n';
    int X = lenx, Y = k - X;
    while(X || Y){
        cout << (X < Y) << ' ';
        if(X < Y) Y -= (X+1);
        else X -= (Y+1);
    }
    cout << '\n';
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    for(cin >> t; t--;){
        cin >> k;
        pro(k);
    }
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |