Submission #85421

# Submission time Handle Problem Language Result Execution time Memory
85421 2018-11-19T20:27:29 Z farukkastamonuda Nice sequence (IZhO18_sequence) C++14
0 / 100
2 ms 544 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 400105
using namespace std;
int t,n,m,B[li],A[li],ans;
bool vis[li];
int gcd(int a,int b){
	return (b==0?a:gcd(b,a%b));
}
void dfs(int node){
	if(vis[node] || node<0 || node>ans) return ;
	vis[node]=true;
	dfs(node-n);
	dfs(node+m);
	A[node]=t++;
}
void solve(){
	scanf("%d %d",&n,&m);
	ans=n+m-1-gcd(n,m);
	t=0;
	fill(vis,vis+ans+1,false);
	for(int i=0;i<=ans;i++){
		dfs(i);
	}
	printf("%d\n",ans);
	for(int i=0;i<ans;i++){
		printf("%d ",A[i]-A[i+1]);
	}
	printf("\n");
}
int main(){
	#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	#endif
	scanf("%d",&t);
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Compilation message

sequence.cpp: In function 'void solve()':
sequence.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
sequence.cpp: In function 'int main()':
sequence.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&t);
  ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 448 KB Ok
2 Incorrect 2 ms 528 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 544 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -