Submission #85426

# Submission time Handle Problem Language Result Execution time Memory
85426 2018-11-19T20:35:28 Z farukkastamonuda Nice sequence (IZhO18_sequence) C++14
43 / 100
13 ms 1280 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
using namespace std;
const int li=4000001;
int tt,t,n,m,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 472 KB Ok
3 Correct 2 ms 472 KB Ok
4 Correct 2 ms 472 KB Ok
5 Correct 2 ms 472 KB Ok
6 Correct 2 ms 472 KB Ok
7 Correct 2 ms 504 KB Ok
8 Correct 2 ms 504 KB Ok
9 Correct 2 ms 620 KB Ok
10 Correct 2 ms 620 KB Ok
11 Correct 2 ms 620 KB Ok
12 Correct 2 ms 620 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 620 KB Ok
2 Correct 2 ms 620 KB Ok
3 Correct 2 ms 620 KB Ok
4 Correct 2 ms 620 KB Ok
5 Correct 2 ms 620 KB Ok
6 Correct 4 ms 620 KB Ok
7 Correct 11 ms 1120 KB Ok
8 Correct 6 ms 1120 KB Ok
9 Correct 13 ms 1280 KB Ok
10 Correct 8 ms 1280 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1280 KB Ok
2 Correct 2 ms 1280 KB Ok
3 Correct 2 ms 1280 KB Ok
4 Correct 2 ms 1280 KB Ok
5 Correct 2 ms 1280 KB Ok
6 Correct 2 ms 1280 KB Ok
7 Correct 2 ms 1280 KB Ok
8 Correct 2 ms 1280 KB Ok
9 Correct 2 ms 1280 KB Ok
10 Correct 2 ms 1280 KB Ok
11 Correct 2 ms 1280 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1280 KB Ok
2 Correct 2 ms 1280 KB Ok
3 Correct 2 ms 1280 KB Ok
4 Correct 2 ms 1280 KB Ok
5 Correct 2 ms 1280 KB Ok
6 Runtime error 3 ms 1280 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 472 KB Ok
3 Correct 2 ms 472 KB Ok
4 Correct 2 ms 472 KB Ok
5 Correct 2 ms 472 KB Ok
6 Correct 2 ms 472 KB Ok
7 Correct 2 ms 504 KB Ok
8 Correct 2 ms 504 KB Ok
9 Correct 2 ms 620 KB Ok
10 Correct 2 ms 620 KB Ok
11 Correct 2 ms 620 KB Ok
12 Correct 2 ms 620 KB Ok
13 Correct 2 ms 1280 KB Ok
14 Correct 2 ms 1280 KB Ok
15 Correct 2 ms 1280 KB Ok
16 Correct 2 ms 1280 KB Ok
17 Correct 2 ms 1280 KB Ok
18 Correct 2 ms 1280 KB Ok
19 Correct 2 ms 1280 KB Ok
20 Correct 2 ms 1280 KB Ok
21 Correct 2 ms 1280 KB Ok
22 Correct 2 ms 1280 KB Ok
23 Correct 2 ms 1280 KB Ok
24 Correct 4 ms 1280 KB Ok
25 Correct 4 ms 1280 KB Ok
26 Correct 4 ms 1280 KB Ok
27 Correct 4 ms 1280 KB Ok
28 Correct 3 ms 1280 KB Ok
29 Correct 3 ms 1280 KB Ok
30 Correct 3 ms 1280 KB Ok
31 Correct 4 ms 1280 KB Ok
32 Correct 4 ms 1280 KB Ok
33 Correct 3 ms 1280 KB Ok
34 Correct 5 ms 1280 KB Ok
35 Correct 5 ms 1280 KB Ok
36 Correct 5 ms 1280 KB Ok
37 Correct 5 ms 1280 KB Ok
38 Correct 6 ms 1280 KB Ok
39 Correct 5 ms 1280 KB Ok
40 Correct 6 ms 1280 KB Ok
41 Correct 5 ms 1280 KB Ok
42 Correct 6 ms 1280 KB Ok
43 Correct 6 ms 1280 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 472 KB Ok
3 Correct 2 ms 472 KB Ok
4 Correct 2 ms 472 KB Ok
5 Correct 2 ms 472 KB Ok
6 Correct 2 ms 472 KB Ok
7 Correct 2 ms 504 KB Ok
8 Correct 2 ms 504 KB Ok
9 Correct 2 ms 620 KB Ok
10 Correct 2 ms 620 KB Ok
11 Correct 2 ms 620 KB Ok
12 Correct 2 ms 620 KB Ok
13 Correct 2 ms 620 KB Ok
14 Correct 2 ms 620 KB Ok
15 Correct 2 ms 620 KB Ok
16 Correct 2 ms 620 KB Ok
17 Correct 2 ms 620 KB Ok
18 Correct 4 ms 620 KB Ok
19 Correct 11 ms 1120 KB Ok
20 Correct 6 ms 1120 KB Ok
21 Correct 13 ms 1280 KB Ok
22 Correct 8 ms 1280 KB Ok
23 Correct 2 ms 1280 KB Ok
24 Correct 2 ms 1280 KB Ok
25 Correct 2 ms 1280 KB Ok
26 Correct 2 ms 1280 KB Ok
27 Correct 2 ms 1280 KB Ok
28 Correct 2 ms 1280 KB Ok
29 Correct 2 ms 1280 KB Ok
30 Correct 2 ms 1280 KB Ok
31 Correct 2 ms 1280 KB Ok
32 Correct 2 ms 1280 KB Ok
33 Correct 2 ms 1280 KB Ok
34 Correct 4 ms 1280 KB Ok
35 Correct 4 ms 1280 KB Ok
36 Correct 4 ms 1280 KB Ok
37 Correct 4 ms 1280 KB Ok
38 Correct 3 ms 1280 KB Ok
39 Correct 3 ms 1280 KB Ok
40 Correct 3 ms 1280 KB Ok
41 Correct 4 ms 1280 KB Ok
42 Correct 4 ms 1280 KB Ok
43 Correct 3 ms 1280 KB Ok
44 Correct 5 ms 1280 KB Ok
45 Correct 5 ms 1280 KB Ok
46 Correct 5 ms 1280 KB Ok
47 Correct 5 ms 1280 KB Ok
48 Correct 6 ms 1280 KB Ok
49 Correct 5 ms 1280 KB Ok
50 Correct 6 ms 1280 KB Ok
51 Correct 5 ms 1280 KB Ok
52 Correct 6 ms 1280 KB Ok
53 Correct 6 ms 1280 KB Ok
54 Runtime error 4 ms 1280 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 472 KB Ok
3 Correct 2 ms 472 KB Ok
4 Correct 2 ms 472 KB Ok
5 Correct 2 ms 472 KB Ok
6 Correct 2 ms 472 KB Ok
7 Correct 2 ms 504 KB Ok
8 Correct 2 ms 504 KB Ok
9 Correct 2 ms 620 KB Ok
10 Correct 2 ms 620 KB Ok
11 Correct 2 ms 620 KB Ok
12 Correct 2 ms 620 KB Ok
13 Correct 2 ms 620 KB Ok
14 Correct 2 ms 620 KB Ok
15 Correct 2 ms 620 KB Ok
16 Correct 2 ms 620 KB Ok
17 Correct 2 ms 620 KB Ok
18 Correct 4 ms 620 KB Ok
19 Correct 11 ms 1120 KB Ok
20 Correct 6 ms 1120 KB Ok
21 Correct 13 ms 1280 KB Ok
22 Correct 8 ms 1280 KB Ok
23 Correct 2 ms 1280 KB Ok
24 Correct 2 ms 1280 KB Ok
25 Correct 2 ms 1280 KB Ok
26 Correct 2 ms 1280 KB Ok
27 Correct 2 ms 1280 KB Ok
28 Correct 2 ms 1280 KB Ok
29 Correct 2 ms 1280 KB Ok
30 Correct 2 ms 1280 KB Ok
31 Correct 2 ms 1280 KB Ok
32 Correct 2 ms 1280 KB Ok
33 Correct 2 ms 1280 KB Ok
34 Correct 2 ms 1280 KB Ok
35 Correct 2 ms 1280 KB Ok
36 Correct 2 ms 1280 KB Ok
37 Correct 2 ms 1280 KB Ok
38 Correct 2 ms 1280 KB Ok
39 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Halted 0 ms 0 KB -