# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
568293 | 2022-05-25T07:01:13 Z | MilosMilutinovic | Nice sequence (IZhO18_sequence) | C++14 | 13 ms | 19512 KB |
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) #define per(i,a,n) for (int i=n-1;i>=a;i--) #define pb push_back #define eb emplace_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef basic_string<int> BI; typedef long long ll; typedef pair<int,int> PII; typedef double db; mt19937 mrand(random_device{}()); const ll mod=1000000007; int rnd(int x) { return mrand() % x;} ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} // head const int N=400505; int n,m,_,deg[N],v[N],t; VI e[N]; bool check(int x) { rep(i,0,x+1) deg[i]=0,e[i].clear(); rep(i,n,x+1) { e[i].pb(i-n); deg[i-n]++; } rep(i,m,x+1) { e[i-m].pb(i); deg[i]++; } t=0; queue<int> q; rep(i,0,x+1) if (deg[i]==0) q.push(i); while (SZ(q)) { int x=q.front(); q.pop(); v[x]=++t; for (int y:e[x]) { deg[y]--; if (deg[y]==0) q.push(y); } } per(i,1,x+1) v[i]-=v[i-1]; rep(i,1,x+1) printf("%d ",v[i]); printf("\n"); } void solve() { scanf("%d%d",&n,&m); int ans=n+m-1-__gcd(n,m); printf("%d\n",ans); check(ans); } int main() { for (scanf("%d",&_);_;_--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 19512 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 19412 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 19412 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 19408 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 19512 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 19512 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 19512 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |