# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58667 | alenam0161 | Nice sequence (IZhO18_sequence) | C++17 | 1137 ms | 44448 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int n,m,len,t=0;
vector<int> ans,used;
int Try(int x){
used[x]=true;
if(x-n>=0&&used[x-n]==false)Try(x-n);
if(x+m<=len&&used[x+m]==false)Try(x+m);
ans[x]=++t;
}
int main(){
int test;
scanf("%d",&test);
for(int i=1;i<=test;++i){
scanf("%d %d",&n,&m);
len = n + m - 1 -__gcd(n,m);t=0;
if(n==m){
printf("%d\n",n-1);for(int i=1;i<n;++i)printf("%d ",i);printf("\n");
}
else{
ans.resize(0);used.resize(0);
ans.resize(len+1,0);
used.resize(len+1,0);
for(int i=0;i<=len;++i){
if(used[i])continue;
Try(i);
}
printf("%d\n",len);for(int i=1;i<=len;++i)printf("%d ",-ans[i]+ans[i-1]);printf("\n");
}
}
return 0;
}
Compilation message (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... |