답안 #85425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85425 2018-11-19T20:34:12 Z farukkastamonuda Nice sequence (IZhO18_sequence) C++14
43 / 100
19 ms 1436 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=400001;
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);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 372 KB Ok
3 Correct 2 ms 448 KB Ok
4 Correct 2 ms 532 KB Ok
5 Correct 2 ms 532 KB Ok
6 Correct 2 ms 532 KB Ok
7 Correct 2 ms 560 KB Ok
8 Correct 2 ms 608 KB Ok
9 Correct 2 ms 608 KB Ok
10 Correct 3 ms 608 KB Ok
11 Correct 2 ms 608 KB Ok
12 Correct 2 ms 652 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 652 KB Ok
2 Correct 3 ms 652 KB Ok
3 Correct 2 ms 652 KB Ok
4 Correct 2 ms 652 KB Ok
5 Correct 2 ms 652 KB Ok
6 Correct 4 ms 652 KB Ok
7 Correct 11 ms 1148 KB Ok
8 Correct 6 ms 1148 KB Ok
9 Correct 12 ms 1436 KB Ok
10 Correct 8 ms 1436 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1436 KB Ok
2 Correct 2 ms 1436 KB Ok
3 Correct 2 ms 1436 KB Ok
4 Correct 2 ms 1436 KB Ok
5 Correct 2 ms 1436 KB Ok
6 Correct 2 ms 1436 KB Ok
7 Correct 2 ms 1436 KB Ok
8 Correct 2 ms 1436 KB Ok
9 Correct 2 ms 1436 KB Ok
10 Correct 2 ms 1436 KB Ok
11 Correct 2 ms 1436 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1436 KB Ok
2 Correct 2 ms 1436 KB Ok
3 Correct 2 ms 1436 KB Ok
4 Correct 3 ms 1436 KB Ok
5 Correct 2 ms 1436 KB Ok
6 Runtime error 3 ms 1436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 372 KB Ok
3 Correct 2 ms 448 KB Ok
4 Correct 2 ms 532 KB Ok
5 Correct 2 ms 532 KB Ok
6 Correct 2 ms 532 KB Ok
7 Correct 2 ms 560 KB Ok
8 Correct 2 ms 608 KB Ok
9 Correct 2 ms 608 KB Ok
10 Correct 3 ms 608 KB Ok
11 Correct 2 ms 608 KB Ok
12 Correct 2 ms 652 KB Ok
13 Correct 2 ms 1436 KB Ok
14 Correct 2 ms 1436 KB Ok
15 Correct 2 ms 1436 KB Ok
16 Correct 2 ms 1436 KB Ok
17 Correct 2 ms 1436 KB Ok
18 Correct 2 ms 1436 KB Ok
19 Correct 2 ms 1436 KB Ok
20 Correct 2 ms 1436 KB Ok
21 Correct 2 ms 1436 KB Ok
22 Correct 2 ms 1436 KB Ok
23 Correct 2 ms 1436 KB Ok
24 Correct 4 ms 1436 KB Ok
25 Correct 4 ms 1436 KB Ok
26 Correct 4 ms 1436 KB Ok
27 Correct 4 ms 1436 KB Ok
28 Correct 3 ms 1436 KB Ok
29 Correct 3 ms 1436 KB Ok
30 Correct 3 ms 1436 KB Ok
31 Correct 19 ms 1436 KB Ok
32 Correct 4 ms 1436 KB Ok
33 Correct 3 ms 1436 KB Ok
34 Correct 5 ms 1436 KB Ok
35 Correct 6 ms 1436 KB Ok
36 Correct 6 ms 1436 KB Ok
37 Correct 6 ms 1436 KB Ok
38 Correct 6 ms 1436 KB Ok
39 Correct 5 ms 1436 KB Ok
40 Correct 5 ms 1436 KB Ok
41 Correct 5 ms 1436 KB Ok
42 Correct 7 ms 1436 KB Ok
43 Correct 8 ms 1436 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 372 KB Ok
3 Correct 2 ms 448 KB Ok
4 Correct 2 ms 532 KB Ok
5 Correct 2 ms 532 KB Ok
6 Correct 2 ms 532 KB Ok
7 Correct 2 ms 560 KB Ok
8 Correct 2 ms 608 KB Ok
9 Correct 2 ms 608 KB Ok
10 Correct 3 ms 608 KB Ok
11 Correct 2 ms 608 KB Ok
12 Correct 2 ms 652 KB Ok
13 Correct 2 ms 652 KB Ok
14 Correct 3 ms 652 KB Ok
15 Correct 2 ms 652 KB Ok
16 Correct 2 ms 652 KB Ok
17 Correct 2 ms 652 KB Ok
18 Correct 4 ms 652 KB Ok
19 Correct 11 ms 1148 KB Ok
20 Correct 6 ms 1148 KB Ok
21 Correct 12 ms 1436 KB Ok
22 Correct 8 ms 1436 KB Ok
23 Correct 2 ms 1436 KB Ok
24 Correct 2 ms 1436 KB Ok
25 Correct 2 ms 1436 KB Ok
26 Correct 2 ms 1436 KB Ok
27 Correct 2 ms 1436 KB Ok
28 Correct 2 ms 1436 KB Ok
29 Correct 2 ms 1436 KB Ok
30 Correct 2 ms 1436 KB Ok
31 Correct 2 ms 1436 KB Ok
32 Correct 2 ms 1436 KB Ok
33 Correct 2 ms 1436 KB Ok
34 Correct 4 ms 1436 KB Ok
35 Correct 4 ms 1436 KB Ok
36 Correct 4 ms 1436 KB Ok
37 Correct 4 ms 1436 KB Ok
38 Correct 3 ms 1436 KB Ok
39 Correct 3 ms 1436 KB Ok
40 Correct 3 ms 1436 KB Ok
41 Correct 19 ms 1436 KB Ok
42 Correct 4 ms 1436 KB Ok
43 Correct 3 ms 1436 KB Ok
44 Correct 5 ms 1436 KB Ok
45 Correct 6 ms 1436 KB Ok
46 Correct 6 ms 1436 KB Ok
47 Correct 6 ms 1436 KB Ok
48 Correct 6 ms 1436 KB Ok
49 Correct 5 ms 1436 KB Ok
50 Correct 5 ms 1436 KB Ok
51 Correct 5 ms 1436 KB Ok
52 Correct 7 ms 1436 KB Ok
53 Correct 8 ms 1436 KB Ok
54 Runtime error 3 ms 1436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 372 KB Ok
3 Correct 2 ms 448 KB Ok
4 Correct 2 ms 532 KB Ok
5 Correct 2 ms 532 KB Ok
6 Correct 2 ms 532 KB Ok
7 Correct 2 ms 560 KB Ok
8 Correct 2 ms 608 KB Ok
9 Correct 2 ms 608 KB Ok
10 Correct 3 ms 608 KB Ok
11 Correct 2 ms 608 KB Ok
12 Correct 2 ms 652 KB Ok
13 Correct 2 ms 652 KB Ok
14 Correct 3 ms 652 KB Ok
15 Correct 2 ms 652 KB Ok
16 Correct 2 ms 652 KB Ok
17 Correct 2 ms 652 KB Ok
18 Correct 4 ms 652 KB Ok
19 Correct 11 ms 1148 KB Ok
20 Correct 6 ms 1148 KB Ok
21 Correct 12 ms 1436 KB Ok
22 Correct 8 ms 1436 KB Ok
23 Correct 2 ms 1436 KB Ok
24 Correct 2 ms 1436 KB Ok
25 Correct 2 ms 1436 KB Ok
26 Correct 2 ms 1436 KB Ok
27 Correct 2 ms 1436 KB Ok
28 Correct 2 ms 1436 KB Ok
29 Correct 2 ms 1436 KB Ok
30 Correct 2 ms 1436 KB Ok
31 Correct 2 ms 1436 KB Ok
32 Correct 2 ms 1436 KB Ok
33 Correct 2 ms 1436 KB Ok
34 Correct 2 ms 1436 KB Ok
35 Correct 2 ms 1436 KB Ok
36 Correct 2 ms 1436 KB Ok
37 Correct 3 ms 1436 KB Ok
38 Correct 2 ms 1436 KB Ok
39 Runtime error 3 ms 1436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Halted 0 ms 0 KB -