제출 #568989

#제출 시각아이디문제언어결과실행 시간메모리
568989MilosMilutinovicNice sequence (IZhO18_sequence)C++14
100 / 100
1419 ms53252 KiB
#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]; void 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; deque<int> q; rep(i,0,x+1) if (deg[i]==0) q.pb(i); while (!q.empty()) { int x=q[0]; q.pop_front(); v[x]=++t; for (int y:e[x]) { deg[y]--; if (deg[y]==0) q.pb(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; }

컴파일 시 표준 에러 (stderr) 메시지

sequence.cpp: In function 'void check(int)':
sequence.cpp:3:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    3 | #define rep(i,a,n) for (int i=a;i<n;i++)
      |                    ^~~
sequence.cpp:51:2: note: in expansion of macro 'rep'
   51 |  rep(i,1,x+1) printf("%d ",v[i]); printf("\n");
      |  ^~~
sequence.cpp:51:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |  rep(i,1,x+1) printf("%d ",v[i]); printf("\n");
      |                                   ^~~~~~
sequence.cpp: In function 'void solve()':
sequence.cpp:54:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
sequence.cpp: In function 'int main()':
sequence.cpp:61:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |  for (scanf("%d",&_);_;_--) {
      |       ~~~~~^~~~~~~~~
#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...