제출 #334684

#제출 시각아이디문제언어결과실행 시간메모리
334684KerimNice sequence (IZhO18_sequence)C++17
100 / 100
1574 ms68924 KiB
#include "bits/stdc++.h"
#define MAXN 400009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>adj[MAXN];
int dp[MAXN],n,m,c,t;
void dfs(int nd){
	if(dp[nd]) return;
	dp[nd]=++c;
	tr(it,adj[nd])
		dfs(*it),umax(dp[nd],dp[*it]+1);
}
void solve(int k){
	for(int i=0;i<=k;i++){
		if(i+n<=k) adj[i].pb(i+n);
		if(i-m>=0) adj[i].pb(i-m);
	}
	for(int i=0;i<=k;i++) dfs(i);
	printf("%d\n",k);
	for(int i=1;i<=k;i++)
		printf("%d ",dp[i]-dp[i-1]); puts("");
	for(int i=0;i<=k;i++)
		adj[i].clear(),dp[i]=0;c=0;
}
int main(){
    scanf("%d",&t);
    while(t--)
		scanf("%d%d",&n,&m),solve(n+m-__gcd(n,m)-1);	
	return 0;
}

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

sequence.cpp: In function 'void solve(int)':
sequence.cpp:35:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |  for(int i=1;i<=k;i++)
      |  ^~~
sequence.cpp:36:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   36 |   printf("%d ",dp[i]-dp[i-1]); puts("");
      |                                ^~~~
sequence.cpp:37:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |  for(int i=0;i<=k;i++)
      |  ^~~
sequence.cpp:38:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   38 |   adj[i].clear(),dp[i]=0;c=0;
      |                          ^
sequence.cpp: In function 'int main()':
sequence.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
sequence.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |   scanf("%d%d",&n,&m),solve(n+m-__gcd(n,m)-1);
      |   ~~~~~^~~~~~~~~~~~~~
#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...