Submission #85424

# Submission time Handle Problem Language Result Execution time Memory
85424 2018-11-19T20:31:51 Z farukkastamonuda Nice sequence (IZhO18_sequence) C++14
43 / 100
13 ms 1352 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 400001
using namespace std;
int tt,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(){
	scanf("%d",&tt);
	for(int i=1;i<=tt;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:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&tt);
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 620 KB Ok
4 Correct 2 ms 624 KB Ok
5 Correct 2 ms 640 KB Ok
6 Correct 2 ms 640 KB Ok
7 Correct 2 ms 640 KB Ok
8 Correct 2 ms 640 KB Ok
9 Correct 2 ms 640 KB Ok
10 Correct 2 ms 640 KB Ok
11 Correct 2 ms 640 KB Ok
12 Correct 2 ms 640 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Ok
2 Correct 2 ms 708 KB Ok
3 Correct 2 ms 708 KB Ok
4 Correct 2 ms 720 KB Ok
5 Correct 2 ms 720 KB Ok
6 Correct 4 ms 736 KB Ok
7 Correct 13 ms 1152 KB Ok
8 Correct 6 ms 1152 KB Ok
9 Correct 12 ms 1292 KB Ok
10 Correct 8 ms 1292 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1292 KB Ok
2 Correct 2 ms 1292 KB Ok
3 Correct 2 ms 1292 KB Ok
4 Correct 2 ms 1292 KB Ok
5 Correct 2 ms 1292 KB Ok
6 Correct 2 ms 1292 KB Ok
7 Correct 2 ms 1292 KB Ok
8 Correct 2 ms 1292 KB Ok
9 Correct 2 ms 1292 KB Ok
10 Correct 2 ms 1292 KB Ok
11 Correct 2 ms 1292 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1292 KB Ok
2 Correct 2 ms 1292 KB Ok
3 Correct 2 ms 1292 KB Ok
4 Correct 2 ms 1292 KB Ok
5 Correct 2 ms 1292 KB Ok
6 Runtime error 3 ms 1292 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 620 KB Ok
4 Correct 2 ms 624 KB Ok
5 Correct 2 ms 640 KB Ok
6 Correct 2 ms 640 KB Ok
7 Correct 2 ms 640 KB Ok
8 Correct 2 ms 640 KB Ok
9 Correct 2 ms 640 KB Ok
10 Correct 2 ms 640 KB Ok
11 Correct 2 ms 640 KB Ok
12 Correct 2 ms 640 KB Ok
13 Correct 2 ms 1292 KB Ok
14 Correct 2 ms 1292 KB Ok
15 Correct 2 ms 1292 KB Ok
16 Correct 2 ms 1292 KB Ok
17 Correct 2 ms 1292 KB Ok
18 Correct 2 ms 1292 KB Ok
19 Correct 2 ms 1292 KB Ok
20 Correct 2 ms 1292 KB Ok
21 Correct 2 ms 1292 KB Ok
22 Correct 2 ms 1292 KB Ok
23 Correct 2 ms 1292 KB Ok
24 Correct 4 ms 1292 KB Ok
25 Correct 4 ms 1292 KB Ok
26 Correct 4 ms 1292 KB Ok
27 Correct 4 ms 1292 KB Ok
28 Correct 3 ms 1292 KB Ok
29 Correct 4 ms 1292 KB Ok
30 Correct 3 ms 1292 KB Ok
31 Correct 4 ms 1292 KB Ok
32 Correct 4 ms 1292 KB Ok
33 Correct 4 ms 1292 KB Ok
34 Correct 7 ms 1292 KB Ok
35 Correct 6 ms 1292 KB Ok
36 Correct 6 ms 1292 KB Ok
37 Correct 6 ms 1292 KB Ok
38 Correct 5 ms 1352 KB Ok
39 Correct 5 ms 1352 KB Ok
40 Correct 5 ms 1352 KB Ok
41 Correct 5 ms 1352 KB Ok
42 Correct 6 ms 1352 KB Ok
43 Correct 6 ms 1352 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 620 KB Ok
4 Correct 2 ms 624 KB Ok
5 Correct 2 ms 640 KB Ok
6 Correct 2 ms 640 KB Ok
7 Correct 2 ms 640 KB Ok
8 Correct 2 ms 640 KB Ok
9 Correct 2 ms 640 KB Ok
10 Correct 2 ms 640 KB Ok
11 Correct 2 ms 640 KB Ok
12 Correct 2 ms 640 KB Ok
13 Correct 2 ms 640 KB Ok
14 Correct 2 ms 708 KB Ok
15 Correct 2 ms 708 KB Ok
16 Correct 2 ms 720 KB Ok
17 Correct 2 ms 720 KB Ok
18 Correct 4 ms 736 KB Ok
19 Correct 13 ms 1152 KB Ok
20 Correct 6 ms 1152 KB Ok
21 Correct 12 ms 1292 KB Ok
22 Correct 8 ms 1292 KB Ok
23 Correct 2 ms 1292 KB Ok
24 Correct 2 ms 1292 KB Ok
25 Correct 2 ms 1292 KB Ok
26 Correct 2 ms 1292 KB Ok
27 Correct 2 ms 1292 KB Ok
28 Correct 2 ms 1292 KB Ok
29 Correct 2 ms 1292 KB Ok
30 Correct 2 ms 1292 KB Ok
31 Correct 2 ms 1292 KB Ok
32 Correct 2 ms 1292 KB Ok
33 Correct 2 ms 1292 KB Ok
34 Correct 4 ms 1292 KB Ok
35 Correct 4 ms 1292 KB Ok
36 Correct 4 ms 1292 KB Ok
37 Correct 4 ms 1292 KB Ok
38 Correct 3 ms 1292 KB Ok
39 Correct 4 ms 1292 KB Ok
40 Correct 3 ms 1292 KB Ok
41 Correct 4 ms 1292 KB Ok
42 Correct 4 ms 1292 KB Ok
43 Correct 4 ms 1292 KB Ok
44 Correct 7 ms 1292 KB Ok
45 Correct 6 ms 1292 KB Ok
46 Correct 6 ms 1292 KB Ok
47 Correct 6 ms 1292 KB Ok
48 Correct 5 ms 1352 KB Ok
49 Correct 5 ms 1352 KB Ok
50 Correct 5 ms 1352 KB Ok
51 Correct 5 ms 1352 KB Ok
52 Correct 6 ms 1352 KB Ok
53 Correct 6 ms 1352 KB Ok
54 Runtime error 3 ms 1352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 620 KB Ok
4 Correct 2 ms 624 KB Ok
5 Correct 2 ms 640 KB Ok
6 Correct 2 ms 640 KB Ok
7 Correct 2 ms 640 KB Ok
8 Correct 2 ms 640 KB Ok
9 Correct 2 ms 640 KB Ok
10 Correct 2 ms 640 KB Ok
11 Correct 2 ms 640 KB Ok
12 Correct 2 ms 640 KB Ok
13 Correct 2 ms 640 KB Ok
14 Correct 2 ms 708 KB Ok
15 Correct 2 ms 708 KB Ok
16 Correct 2 ms 720 KB Ok
17 Correct 2 ms 720 KB Ok
18 Correct 4 ms 736 KB Ok
19 Correct 13 ms 1152 KB Ok
20 Correct 6 ms 1152 KB Ok
21 Correct 12 ms 1292 KB Ok
22 Correct 8 ms 1292 KB Ok
23 Correct 2 ms 1292 KB Ok
24 Correct 2 ms 1292 KB Ok
25 Correct 2 ms 1292 KB Ok
26 Correct 2 ms 1292 KB Ok
27 Correct 2 ms 1292 KB Ok
28 Correct 2 ms 1292 KB Ok
29 Correct 2 ms 1292 KB Ok
30 Correct 2 ms 1292 KB Ok
31 Correct 2 ms 1292 KB Ok
32 Correct 2 ms 1292 KB Ok
33 Correct 2 ms 1292 KB Ok
34 Correct 2 ms 1292 KB Ok
35 Correct 2 ms 1292 KB Ok
36 Correct 2 ms 1292 KB Ok
37 Correct 2 ms 1292 KB Ok
38 Correct 2 ms 1292 KB Ok
39 Runtime error 3 ms 1292 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Halted 0 ms 0 KB -