Submission #58667

#TimeUsernameProblemLanguageResultExecution timeMemory
58667alenam0161Nice sequence (IZhO18_sequence)C++17
100 / 100
1137 ms44448 KiB
#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)

sequence.cpp: In function 'int Try(int)':
sequence.cpp:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
sequence.cpp: In function 'int main()':
sequence.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&test);
     ~~~~~^~~~~~~~~~~~
sequence.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&n,&m);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...