# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
46052 | aome | Binary Subsequences (info1cup17_binary) | C++17 | 665 ms | 608 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
void solve() {
cin >> n;
int cnt = 2;
int minLen = n;
pair<int, int> state = {0, n};
for (int i = 1; i < (n + 1) / 2; ++i) {
pair<int, int> cur = {i, n - i};
int curLen = 0;
while (cur.first != cur.second) {
if (cur.first > cur.second) {
curLen += cur.first / (cur.second + 1);
cur.first %= cur.second + 1;
}
else {
curLen += cur.second / (cur.first + 1);
cur.second %= cur.first + 1;
}
}
// cout << cur.first << ' ' << cur.second << ' ' << curLen << '\n';
if (!cur.first) cnt += 2;
if (curLen < minLen && !cur.first) {
minLen = curLen, state = {i, n - i};
}
}
vector<int> vec;
pair<int, int> cur = state;
while (cur.first != cur.second) {
if (cur.first > cur.second) {
cur.first -= cur.second + 1;
vec.push_back(0);
}
else {
cur.second -= cur.first + 1;
vec.push_back(1);
}
}
reverse(vec.begin(), vec.end());
cout << cnt << '\n';
for (auto i : vec) cout << i << ' '; cout << '\n';
}
int main() {
ios::sync_with_stdio(false);
int t; 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... |