Submission #92362

#TimeUsernameProblemLanguageResultExecution timeMemory
92362AbelyanNice sequence (IZhO18_sequence)C++17
100 / 100
392 ms35192 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i,a) for (int i=0;i<(a);++i) #define FORR(i,a) for (int i=(a)-1;i>=0;i--) #define FORT(i,a,b) for (int i=(a);i<=(b);++i) #define FORTR(i,a,b) for (int i=(b);i>=(a);--i) #define trav(i,v) for (auto i : v) #define gcd __gcd #define fr first #define sc second #define x real #define y imag typedef long long ll; typedef long double ld; const int N = 4e5+6; const int K = 406; int pref[N],timer=1; int n,m,qan; void dfs(int v){ //cout<<v<<endl; if (v-n>=0 && !pref[v-n])dfs(v-n); if (v+m<=qan && !pref[v+m])dfs(v+m); pref[v]=timer++; } int main(){ ios_base::sync_with_stdio(false); int t; cin>>t; //assert(t==3); while(t--){ cin>>m>>n; //assert((m==3 && n==1) || (m==2 && n==3) || (m==1 && n==1)); qan=n+m-1-gcd(n,m); cout<<qan<<endl; FORT(i,0,qan){ if (!pref[i])dfs(i); } //FOR(i,qan+1)cout<<pref[i]<<" "; //cout<<endl; FORT(i,1,qan){ cout<<pref[i]-pref[i-1]<<" "; pref[i-1]=0; } pref[qan]=0; timer=1; cout<<endl; } return 0; }
#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...