# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40508 | Akylbek | Nice sequence (IZhO18_sequence) | C++14 | 1743 ms | 73296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N = 4e5 + 10;
const int md = 1e9 + 7;
int T;
int n, m;
vector <int> g[N];
int p[N];
int used[N];
vector <int> ord;
void dfs (int v) {
used[v] = 1;
for (auto to : g[v]) {
if (!used[to]) dfs(to);
}
ord.pb(v);
}
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d%d", &n, &m);
int len = n + m - __gcd(n, m) - 1;
for (int i = n; i <= len; i++) {
g[i - n].pb(i);
}
for (int i = m; i <= len; i++) {
g[i].pb(i - m);
}
for (int i = 0; i <= len; i++) {
if (!used[i]) {
dfs(i);
}
}
for (int i = 0; i < len + 1; i++) {
if (ord[i] == 0) {
p[ord[i]] = 0;
continue;
}
if (i == 0) {
p[ord[i]] = -1000000;
continue;
}
p[ord[i]] = p[ord[i - 1]] + 1;
}
cout << len << '\n';
for (int i = 1; i <= len; i++) {
cout << p[i] - p[i - 1] << ' ';
}
cout << '\n';
for (int i = 0; i <= len; i++) {
g[i].clear();
used[i] = 0;
}
ord.clear();
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |