# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85422 | 2018-11-19T20:28:08 Z | farukkastamonuda | Nice sequence (IZhO18_sequence) | C++14 | 12 ms | 1856 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 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Ok |
2 | Correct | 2 ms | 500 KB | Ok |
3 | Correct | 2 ms | 500 KB | Ok |
4 | Correct | 2 ms | 552 KB | Ok |
5 | Correct | 2 ms | 600 KB | Ok |
6 | Correct | 2 ms | 600 KB | Ok |
7 | Correct | 2 ms | 708 KB | Ok |
8 | Correct | 2 ms | 708 KB | Ok |
9 | Correct | 2 ms | 756 KB | Ok |
10 | Correct | 2 ms | 756 KB | Ok |
11 | Correct | 2 ms | 756 KB | Ok |
12 | Correct | 2 ms | 756 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 820 KB | Ok |
2 | Correct | 2 ms | 824 KB | Ok |
3 | Correct | 2 ms | 824 KB | Ok |
4 | Correct | 2 ms | 824 KB | Ok |
5 | Correct | 2 ms | 824 KB | Ok |
6 | Correct | 4 ms | 824 KB | Ok |
7 | Correct | 11 ms | 1308 KB | Ok |
8 | Correct | 6 ms | 1308 KB | Ok |
9 | Correct | 12 ms | 1456 KB | Ok |
10 | Correct | 8 ms | 1456 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1456 KB | Ok |
2 | Correct | 2 ms | 1456 KB | Ok |
3 | Correct | 2 ms | 1456 KB | Ok |
4 | Correct | 2 ms | 1456 KB | Ok |
5 | Correct | 2 ms | 1456 KB | Ok |
6 | Correct | 2 ms | 1456 KB | Ok |
7 | Correct | 2 ms | 1456 KB | Ok |
8 | Correct | 2 ms | 1456 KB | Ok |
9 | Correct | 2 ms | 1456 KB | Ok |
10 | Correct | 2 ms | 1456 KB | Ok |
11 | Correct | 2 ms | 1456 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1456 KB | Ok |
2 | Correct | 2 ms | 1456 KB | Ok |
3 | Correct | 3 ms | 1456 KB | Ok |
4 | Correct | 2 ms | 1456 KB | Ok |
5 | Correct | 2 ms | 1456 KB | Ok |
6 | Runtime error | 3 ms | 1456 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 | 500 KB | Ok |
3 | Correct | 2 ms | 500 KB | Ok |
4 | Correct | 2 ms | 552 KB | Ok |
5 | Correct | 2 ms | 600 KB | Ok |
6 | Correct | 2 ms | 600 KB | Ok |
7 | Correct | 2 ms | 708 KB | Ok |
8 | Correct | 2 ms | 708 KB | Ok |
9 | Correct | 2 ms | 756 KB | Ok |
10 | Correct | 2 ms | 756 KB | Ok |
11 | Correct | 2 ms | 756 KB | Ok |
12 | Correct | 2 ms | 756 KB | Ok |
13 | Correct | 2 ms | 1456 KB | Ok |
14 | Correct | 2 ms | 1456 KB | Ok |
15 | Correct | 2 ms | 1456 KB | Ok |
16 | Correct | 2 ms | 1456 KB | Ok |
17 | Correct | 2 ms | 1456 KB | Ok |
18 | Correct | 2 ms | 1456 KB | Ok |
19 | Correct | 2 ms | 1456 KB | Ok |
20 | Correct | 2 ms | 1456 KB | Ok |
21 | Correct | 2 ms | 1456 KB | Ok |
22 | Correct | 2 ms | 1456 KB | Ok |
23 | Correct | 2 ms | 1456 KB | Ok |
24 | Correct | 4 ms | 1456 KB | Ok |
25 | Correct | 4 ms | 1456 KB | Ok |
26 | Correct | 4 ms | 1456 KB | Ok |
27 | Correct | 3 ms | 1456 KB | Ok |
28 | Correct | 3 ms | 1456 KB | Ok |
29 | Correct | 3 ms | 1492 KB | Ok |
30 | Correct | 3 ms | 1492 KB | Ok |
31 | Correct | 4 ms | 1492 KB | Ok |
32 | Correct | 3 ms | 1492 KB | Ok |
33 | Correct | 3 ms | 1528 KB | Ok |
34 | Correct | 6 ms | 1616 KB | Ok |
35 | Correct | 5 ms | 1696 KB | Ok |
36 | Correct | 5 ms | 1700 KB | Ok |
37 | Correct | 6 ms | 1720 KB | Ok |
38 | Correct | 7 ms | 1720 KB | Ok |
39 | Correct | 5 ms | 1720 KB | Ok |
40 | Correct | 5 ms | 1744 KB | Ok |
41 | Correct | 5 ms | 1744 KB | Ok |
42 | Correct | 5 ms | 1856 KB | Ok |
43 | Correct | 5 ms | 1856 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Ok |
2 | Correct | 2 ms | 500 KB | Ok |
3 | Correct | 2 ms | 500 KB | Ok |
4 | Correct | 2 ms | 552 KB | Ok |
5 | Correct | 2 ms | 600 KB | Ok |
6 | Correct | 2 ms | 600 KB | Ok |
7 | Correct | 2 ms | 708 KB | Ok |
8 | Correct | 2 ms | 708 KB | Ok |
9 | Correct | 2 ms | 756 KB | Ok |
10 | Correct | 2 ms | 756 KB | Ok |
11 | Correct | 2 ms | 756 KB | Ok |
12 | Correct | 2 ms | 756 KB | Ok |
13 | Correct | 2 ms | 820 KB | Ok |
14 | Correct | 2 ms | 824 KB | Ok |
15 | Correct | 2 ms | 824 KB | Ok |
16 | Correct | 2 ms | 824 KB | Ok |
17 | Correct | 2 ms | 824 KB | Ok |
18 | Correct | 4 ms | 824 KB | Ok |
19 | Correct | 11 ms | 1308 KB | Ok |
20 | Correct | 6 ms | 1308 KB | Ok |
21 | Correct | 12 ms | 1456 KB | Ok |
22 | Correct | 8 ms | 1456 KB | Ok |
23 | Correct | 2 ms | 1456 KB | Ok |
24 | Correct | 2 ms | 1456 KB | Ok |
25 | Correct | 2 ms | 1456 KB | Ok |
26 | Correct | 2 ms | 1456 KB | Ok |
27 | Correct | 2 ms | 1456 KB | Ok |
28 | Correct | 2 ms | 1456 KB | Ok |
29 | Correct | 2 ms | 1456 KB | Ok |
30 | Correct | 2 ms | 1456 KB | Ok |
31 | Correct | 2 ms | 1456 KB | Ok |
32 | Correct | 2 ms | 1456 KB | Ok |
33 | Correct | 2 ms | 1456 KB | Ok |
34 | Correct | 4 ms | 1456 KB | Ok |
35 | Correct | 4 ms | 1456 KB | Ok |
36 | Correct | 4 ms | 1456 KB | Ok |
37 | Correct | 3 ms | 1456 KB | Ok |
38 | Correct | 3 ms | 1456 KB | Ok |
39 | Correct | 3 ms | 1492 KB | Ok |
40 | Correct | 3 ms | 1492 KB | Ok |
41 | Correct | 4 ms | 1492 KB | Ok |
42 | Correct | 3 ms | 1492 KB | Ok |
43 | Correct | 3 ms | 1528 KB | Ok |
44 | Correct | 6 ms | 1616 KB | Ok |
45 | Correct | 5 ms | 1696 KB | Ok |
46 | Correct | 5 ms | 1700 KB | Ok |
47 | Correct | 6 ms | 1720 KB | Ok |
48 | Correct | 7 ms | 1720 KB | Ok |
49 | Correct | 5 ms | 1720 KB | Ok |
50 | Correct | 5 ms | 1744 KB | Ok |
51 | Correct | 5 ms | 1744 KB | Ok |
52 | Correct | 5 ms | 1856 KB | Ok |
53 | Correct | 5 ms | 1856 KB | Ok |
54 | Runtime error | 3 ms | 1856 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 | 500 KB | Ok |
3 | Correct | 2 ms | 500 KB | Ok |
4 | Correct | 2 ms | 552 KB | Ok |
5 | Correct | 2 ms | 600 KB | Ok |
6 | Correct | 2 ms | 600 KB | Ok |
7 | Correct | 2 ms | 708 KB | Ok |
8 | Correct | 2 ms | 708 KB | Ok |
9 | Correct | 2 ms | 756 KB | Ok |
10 | Correct | 2 ms | 756 KB | Ok |
11 | Correct | 2 ms | 756 KB | Ok |
12 | Correct | 2 ms | 756 KB | Ok |
13 | Correct | 2 ms | 820 KB | Ok |
14 | Correct | 2 ms | 824 KB | Ok |
15 | Correct | 2 ms | 824 KB | Ok |
16 | Correct | 2 ms | 824 KB | Ok |
17 | Correct | 2 ms | 824 KB | Ok |
18 | Correct | 4 ms | 824 KB | Ok |
19 | Correct | 11 ms | 1308 KB | Ok |
20 | Correct | 6 ms | 1308 KB | Ok |
21 | Correct | 12 ms | 1456 KB | Ok |
22 | Correct | 8 ms | 1456 KB | Ok |
23 | Correct | 2 ms | 1456 KB | Ok |
24 | Correct | 2 ms | 1456 KB | Ok |
25 | Correct | 2 ms | 1456 KB | Ok |
26 | Correct | 2 ms | 1456 KB | Ok |
27 | Correct | 2 ms | 1456 KB | Ok |
28 | Correct | 2 ms | 1456 KB | Ok |
29 | Correct | 2 ms | 1456 KB | Ok |
30 | Correct | 2 ms | 1456 KB | Ok |
31 | Correct | 2 ms | 1456 KB | Ok |
32 | Correct | 2 ms | 1456 KB | Ok |
33 | Correct | 2 ms | 1456 KB | Ok |
34 | Correct | 2 ms | 1456 KB | Ok |
35 | Correct | 2 ms | 1456 KB | Ok |
36 | Correct | 3 ms | 1456 KB | Ok |
37 | Correct | 2 ms | 1456 KB | Ok |
38 | Correct | 2 ms | 1456 KB | Ok |
39 | Runtime error | 3 ms | 1456 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
40 | Halted | 0 ms | 0 KB | - |