Submission #334684

# Submission time Handle Problem Language Result Execution time Memory
334684 2020-12-09T18:51:01 Z Kerim Nice sequence (IZhO18_sequence) C++17
100 / 100
1574 ms 68924 KB
#include "bits/stdc++.h"
#define MAXN 400009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>adj[MAXN];
int dp[MAXN],n,m,c,t;
void dfs(int nd){
	if(dp[nd]) return;
	dp[nd]=++c;
	tr(it,adj[nd])
		dfs(*it),umax(dp[nd],dp[*it]+1);
}
void solve(int k){
	for(int i=0;i<=k;i++){
		if(i+n<=k) adj[i].pb(i+n);
		if(i-m>=0) adj[i].pb(i-m);
	}
	for(int i=0;i<=k;i++) dfs(i);
	printf("%d\n",k);
	for(int i=1;i<=k;i++)
		printf("%d ",dp[i]-dp[i-1]); puts("");
	for(int i=0;i<=k;i++)
		adj[i].clear(),dp[i]=0;c=0;
}
int main(){
    scanf("%d",&t);
    while(t--)
		scanf("%d%d",&n,&m),solve(n+m-__gcd(n,m)-1);	
	return 0;
}

Compilation message

sequence.cpp: In function 'void solve(int)':
sequence.cpp:35:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |  for(int i=1;i<=k;i++)
      |  ^~~
sequence.cpp:36:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   36 |   printf("%d ",dp[i]-dp[i-1]); puts("");
      |                                ^~~~
sequence.cpp:37:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |  for(int i=0;i<=k;i++)
      |  ^~~
sequence.cpp:38:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   38 |   adj[i].clear(),dp[i]=0;c=0;
      |                          ^
sequence.cpp: In function 'int main()':
sequence.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
sequence.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |   scanf("%d%d",&n,&m),solve(n+m-__gcd(n,m)-1);
      |   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Ok
2 Correct 7 ms 9708 KB Ok
3 Correct 7 ms 9708 KB Ok
4 Correct 7 ms 9708 KB Ok
5 Correct 7 ms 9708 KB Ok
6 Correct 7 ms 9708 KB Ok
7 Correct 7 ms 9708 KB Ok
8 Correct 7 ms 9708 KB Ok
9 Correct 7 ms 9708 KB Ok
10 Correct 7 ms 9708 KB Ok
11 Correct 8 ms 9708 KB Ok
12 Correct 7 ms 9708 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9708 KB Ok
2 Correct 7 ms 9836 KB Ok
3 Correct 7 ms 9708 KB Ok
4 Correct 7 ms 9708 KB Ok
5 Correct 7 ms 9708 KB Ok
6 Correct 9 ms 9836 KB Ok
7 Correct 18 ms 10604 KB Ok
8 Correct 18 ms 10092 KB Ok
9 Correct 20 ms 10732 KB Ok
10 Correct 15 ms 10348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Ok
2 Correct 7 ms 9708 KB Ok
3 Correct 7 ms 9708 KB Ok
4 Correct 7 ms 9708 KB Ok
5 Correct 7 ms 9708 KB Ok
6 Correct 7 ms 9708 KB Ok
7 Correct 8 ms 9708 KB Ok
8 Correct 6 ms 9708 KB Ok
9 Correct 7 ms 9708 KB Ok
10 Correct 7 ms 9708 KB Ok
11 Correct 7 ms 9708 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Ok
2 Correct 7 ms 9708 KB Ok
3 Correct 7 ms 9708 KB Ok
4 Correct 6 ms 9708 KB Ok
5 Correct 7 ms 9708 KB Ok
6 Correct 120 ms 21868 KB Ok
7 Correct 113 ms 28156 KB Ok
8 Correct 195 ms 30828 KB Ok
9 Correct 150 ms 28396 KB Ok
10 Correct 88 ms 19180 KB Ok
11 Correct 139 ms 24684 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Ok
2 Correct 7 ms 9708 KB Ok
3 Correct 7 ms 9708 KB Ok
4 Correct 7 ms 9708 KB Ok
5 Correct 7 ms 9708 KB Ok
6 Correct 7 ms 9708 KB Ok
7 Correct 7 ms 9708 KB Ok
8 Correct 7 ms 9708 KB Ok
9 Correct 7 ms 9708 KB Ok
10 Correct 7 ms 9708 KB Ok
11 Correct 8 ms 9708 KB Ok
12 Correct 7 ms 9708 KB Ok
13 Correct 7 ms 9708 KB Ok
14 Correct 7 ms 9708 KB Ok
15 Correct 7 ms 9708 KB Ok
16 Correct 7 ms 9708 KB Ok
17 Correct 7 ms 9708 KB Ok
18 Correct 7 ms 9708 KB Ok
19 Correct 8 ms 9708 KB Ok
20 Correct 6 ms 9708 KB Ok
21 Correct 7 ms 9708 KB Ok
22 Correct 7 ms 9708 KB Ok
23 Correct 7 ms 9708 KB Ok
24 Correct 9 ms 9836 KB Ok
25 Correct 9 ms 9868 KB Ok
26 Correct 9 ms 9836 KB Ok
27 Correct 9 ms 9836 KB Ok
28 Correct 8 ms 9836 KB Ok
29 Correct 8 ms 9836 KB Ok
30 Correct 9 ms 9836 KB Ok
31 Correct 9 ms 9836 KB Ok
32 Correct 9 ms 9836 KB Ok
33 Correct 9 ms 9836 KB Ok
34 Correct 11 ms 10092 KB Ok
35 Correct 11 ms 10092 KB Ok
36 Correct 11 ms 10092 KB Ok
37 Correct 11 ms 10092 KB Ok
38 Correct 11 ms 10092 KB Ok
39 Correct 11 ms 10092 KB Ok
40 Correct 12 ms 10092 KB Ok
41 Correct 11 ms 10092 KB Ok
42 Correct 11 ms 10092 KB Ok
43 Correct 13 ms 10220 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Ok
2 Correct 7 ms 9708 KB Ok
3 Correct 7 ms 9708 KB Ok
4 Correct 7 ms 9708 KB Ok
5 Correct 7 ms 9708 KB Ok
6 Correct 7 ms 9708 KB Ok
7 Correct 7 ms 9708 KB Ok
8 Correct 7 ms 9708 KB Ok
9 Correct 7 ms 9708 KB Ok
10 Correct 7 ms 9708 KB Ok
11 Correct 8 ms 9708 KB Ok
12 Correct 7 ms 9708 KB Ok
13 Correct 8 ms 9708 KB Ok
14 Correct 7 ms 9836 KB Ok
15 Correct 7 ms 9708 KB Ok
16 Correct 7 ms 9708 KB Ok
17 Correct 7 ms 9708 KB Ok
18 Correct 9 ms 9836 KB Ok
19 Correct 18 ms 10604 KB Ok
20 Correct 18 ms 10092 KB Ok
21 Correct 20 ms 10732 KB Ok
22 Correct 15 ms 10348 KB Ok
23 Correct 7 ms 9708 KB Ok
24 Correct 7 ms 9708 KB Ok
25 Correct 7 ms 9708 KB Ok
26 Correct 7 ms 9708 KB Ok
27 Correct 7 ms 9708 KB Ok
28 Correct 7 ms 9708 KB Ok
29 Correct 8 ms 9708 KB Ok
30 Correct 6 ms 9708 KB Ok
31 Correct 7 ms 9708 KB Ok
32 Correct 7 ms 9708 KB Ok
33 Correct 7 ms 9708 KB Ok
34 Correct 9 ms 9836 KB Ok
35 Correct 9 ms 9868 KB Ok
36 Correct 9 ms 9836 KB Ok
37 Correct 9 ms 9836 KB Ok
38 Correct 8 ms 9836 KB Ok
39 Correct 8 ms 9836 KB Ok
40 Correct 9 ms 9836 KB Ok
41 Correct 9 ms 9836 KB Ok
42 Correct 9 ms 9836 KB Ok
43 Correct 9 ms 9836 KB Ok
44 Correct 11 ms 10092 KB Ok
45 Correct 11 ms 10092 KB Ok
46 Correct 11 ms 10092 KB Ok
47 Correct 11 ms 10092 KB Ok
48 Correct 11 ms 10092 KB Ok
49 Correct 11 ms 10092 KB Ok
50 Correct 12 ms 10092 KB Ok
51 Correct 11 ms 10092 KB Ok
52 Correct 11 ms 10092 KB Ok
53 Correct 13 ms 10220 KB Ok
54 Correct 96 ms 14700 KB Ok
55 Correct 105 ms 15084 KB Ok
56 Correct 104 ms 15084 KB Ok
57 Correct 79 ms 14060 KB Ok
58 Correct 93 ms 14444 KB Ok
59 Correct 90 ms 14060 KB Ok
60 Correct 78 ms 13804 KB Ok
61 Correct 81 ms 14316 KB Ok
62 Correct 103 ms 14700 KB Ok
63 Correct 86 ms 14060 KB Ok
64 Correct 111 ms 14956 KB Ok
65 Correct 98 ms 14572 KB Ok
66 Correct 88 ms 14444 KB Ok
67 Correct 78 ms 14188 KB Ok
68 Correct 94 ms 14572 KB Ok
69 Correct 232 ms 23788 KB Ok
70 Correct 256 ms 24300 KB Ok
71 Correct 232 ms 23788 KB Ok
72 Correct 232 ms 23916 KB Ok
73 Correct 246 ms 23148 KB Ok
74 Correct 239 ms 22764 KB Ok
75 Correct 214 ms 23020 KB Ok
76 Correct 256 ms 24044 KB Ok
77 Correct 224 ms 22508 KB Ok
78 Correct 255 ms 22764 KB Ok
79 Correct 240 ms 23404 KB Ok
80 Correct 222 ms 23660 KB Ok
81 Correct 225 ms 22892 KB Ok
82 Correct 240 ms 23404 KB Ok
83 Correct 203 ms 22892 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Ok
2 Correct 7 ms 9708 KB Ok
3 Correct 7 ms 9708 KB Ok
4 Correct 7 ms 9708 KB Ok
5 Correct 7 ms 9708 KB Ok
6 Correct 7 ms 9708 KB Ok
7 Correct 7 ms 9708 KB Ok
8 Correct 7 ms 9708 KB Ok
9 Correct 7 ms 9708 KB Ok
10 Correct 7 ms 9708 KB Ok
11 Correct 8 ms 9708 KB Ok
12 Correct 7 ms 9708 KB Ok
13 Correct 8 ms 9708 KB Ok
14 Correct 7 ms 9836 KB Ok
15 Correct 7 ms 9708 KB Ok
16 Correct 7 ms 9708 KB Ok
17 Correct 7 ms 9708 KB Ok
18 Correct 9 ms 9836 KB Ok
19 Correct 18 ms 10604 KB Ok
20 Correct 18 ms 10092 KB Ok
21 Correct 20 ms 10732 KB Ok
22 Correct 15 ms 10348 KB Ok
23 Correct 7 ms 9708 KB Ok
24 Correct 7 ms 9708 KB Ok
25 Correct 7 ms 9708 KB Ok
26 Correct 7 ms 9708 KB Ok
27 Correct 7 ms 9708 KB Ok
28 Correct 7 ms 9708 KB Ok
29 Correct 8 ms 9708 KB Ok
30 Correct 6 ms 9708 KB Ok
31 Correct 7 ms 9708 KB Ok
32 Correct 7 ms 9708 KB Ok
33 Correct 7 ms 9708 KB Ok
34 Correct 7 ms 9708 KB Ok
35 Correct 7 ms 9708 KB Ok
36 Correct 7 ms 9708 KB Ok
37 Correct 6 ms 9708 KB Ok
38 Correct 7 ms 9708 KB Ok
39 Correct 120 ms 21868 KB Ok
40 Correct 113 ms 28156 KB Ok
41 Correct 195 ms 30828 KB Ok
42 Correct 150 ms 28396 KB Ok
43 Correct 88 ms 19180 KB Ok
44 Correct 139 ms 24684 KB Ok
45 Correct 9 ms 9836 KB Ok
46 Correct 9 ms 9868 KB Ok
47 Correct 9 ms 9836 KB Ok
48 Correct 9 ms 9836 KB Ok
49 Correct 8 ms 9836 KB Ok
50 Correct 8 ms 9836 KB Ok
51 Correct 9 ms 9836 KB Ok
52 Correct 9 ms 9836 KB Ok
53 Correct 9 ms 9836 KB Ok
54 Correct 9 ms 9836 KB Ok
55 Correct 11 ms 10092 KB Ok
56 Correct 11 ms 10092 KB Ok
57 Correct 11 ms 10092 KB Ok
58 Correct 11 ms 10092 KB Ok
59 Correct 11 ms 10092 KB Ok
60 Correct 11 ms 10092 KB Ok
61 Correct 12 ms 10092 KB Ok
62 Correct 11 ms 10092 KB Ok
63 Correct 11 ms 10092 KB Ok
64 Correct 13 ms 10220 KB Ok
65 Correct 96 ms 14700 KB Ok
66 Correct 105 ms 15084 KB Ok
67 Correct 104 ms 15084 KB Ok
68 Correct 79 ms 14060 KB Ok
69 Correct 93 ms 14444 KB Ok
70 Correct 90 ms 14060 KB Ok
71 Correct 78 ms 13804 KB Ok
72 Correct 81 ms 14316 KB Ok
73 Correct 103 ms 14700 KB Ok
74 Correct 86 ms 14060 KB Ok
75 Correct 111 ms 14956 KB Ok
76 Correct 98 ms 14572 KB Ok
77 Correct 88 ms 14444 KB Ok
78 Correct 78 ms 14188 KB Ok
79 Correct 94 ms 14572 KB Ok
80 Correct 232 ms 23788 KB Ok
81 Correct 256 ms 24300 KB Ok
82 Correct 232 ms 23788 KB Ok
83 Correct 232 ms 23916 KB Ok
84 Correct 246 ms 23148 KB Ok
85 Correct 239 ms 22764 KB Ok
86 Correct 214 ms 23020 KB Ok
87 Correct 256 ms 24044 KB Ok
88 Correct 224 ms 22508 KB Ok
89 Correct 255 ms 22764 KB Ok
90 Correct 240 ms 23404 KB Ok
91 Correct 222 ms 23660 KB Ok
92 Correct 225 ms 22892 KB Ok
93 Correct 240 ms 23404 KB Ok
94 Correct 203 ms 22892 KB Ok
95 Correct 228 ms 22380 KB Ok
96 Correct 314 ms 27884 KB Ok
97 Correct 295 ms 24684 KB Ok
98 Correct 233 ms 24772 KB Ok
99 Correct 276 ms 24428 KB Ok
100 Correct 276 ms 24044 KB Ok
101 Correct 281 ms 26604 KB Ok
102 Correct 279 ms 24940 KB Ok
103 Correct 267 ms 25764 KB Ok
104 Correct 324 ms 27500 KB Ok
105 Correct 311 ms 27756 KB Ok
106 Correct 275 ms 27884 KB Ok
107 Correct 296 ms 26860 KB Ok
108 Correct 329 ms 27628 KB Ok
109 Correct 307 ms 28652 KB Ok
110 Correct 1225 ms 66412 KB Ok
111 Correct 1438 ms 68488 KB Ok
112 Correct 1411 ms 64876 KB Ok
113 Correct 1362 ms 68924 KB Ok
114 Correct 1401 ms 68844 KB Ok
115 Correct 1437 ms 65900 KB Ok
116 Correct 1551 ms 68524 KB Ok
117 Correct 1432 ms 67948 KB Ok
118 Correct 1378 ms 68648 KB Ok
119 Correct 1386 ms 67028 KB Ok
120 Correct 1450 ms 67092 KB Ok
121 Correct 1402 ms 67224 KB Ok
122 Correct 1420 ms 66636 KB Ok
123 Correct 1574 ms 68656 KB Ok
124 Correct 1359 ms 62608 KB Ok
125 Correct 532 ms 52716 KB Ok