Submission #40507

# Submission time Handle Problem Language Result Execution time Memory
40507 2018-02-03T08:58:40 Z Akylbek Nice sequence (IZhO18_sequence) C++14
76 / 100
322 ms 28728 KB
#include <bits/stdc++.h>

#define ll long long

#define pb push_back

using namespace std;

const int N = 2e5 + 10;
const int md = 1e9 + 7;

int T;

int n, m;

vector <int> g[N];

int p[N];

int used[N];

vector <int> ord;

void dfs (int v) {
 used[v] = 1;
 for (auto to : g[v]) {
  if (!used[to]) dfs(to);
 }
 ord.pb(v);
}

int main() {
 scanf("%d", &T);
 while (T--) {
  scanf("%d%d", &n, &m);
  int len = n + m - __gcd(n, m) - 1;
  for (int i = n; i <= len; i++) {
   g[i - n].pb(i);
  }
  for (int i = m; i <= len; i++) {
   g[i].pb(i - m);
  }
  for (int i = 0; i <= len; i++) {
   if (!used[i]) {
    dfs(i);
   }
  }
  for (int i = 0; i < len + 1; i++) {
   if (ord[i] == 0) {
    p[ord[i]] = 0;
    continue;
   }
   if (i == 0) {
    p[ord[i]] = -1000000;
    continue;
   }
   p[ord[i]] = p[ord[i - 1]] + 1;
  }
  cout << len << '\n';
  for (int i = 1; i <= len; i++) {
   cout << p[i] - p[i - 1] << ' ';
  }
  cout << '\n';
  for (int i = 0; i <= len; i++) {
   g[i].clear();
   used[i] = 0;
  }
  ord.clear();
 }
 return 0;
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:33:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &T);
                 ^
sequence.cpp:35:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &m);
                        ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Ok
2 Correct 5 ms 5088 KB Ok
3 Correct 5 ms 5160 KB Ok
4 Correct 5 ms 5232 KB Ok
5 Correct 6 ms 5232 KB Ok
6 Correct 6 ms 5232 KB Ok
7 Correct 6 ms 5232 KB Ok
8 Correct 5 ms 5232 KB Ok
9 Correct 6 ms 5232 KB Ok
10 Correct 5 ms 5232 KB Ok
11 Correct 6 ms 5296 KB Ok
12 Correct 24 ms 5296 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5340 KB Ok
2 Correct 5 ms 5340 KB Ok
3 Correct 5 ms 5340 KB Ok
4 Correct 5 ms 5340 KB Ok
5 Correct 5 ms 5340 KB Ok
6 Correct 8 ms 5484 KB Ok
7 Correct 17 ms 6508 KB Ok
8 Correct 12 ms 6508 KB Ok
9 Correct 19 ms 6652 KB Ok
10 Correct 14 ms 6652 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6652 KB Ok
2 Correct 6 ms 6652 KB Ok
3 Correct 5 ms 6652 KB Ok
4 Correct 5 ms 6652 KB Ok
5 Correct 5 ms 6652 KB Ok
6 Correct 5 ms 6652 KB Ok
7 Correct 5 ms 6652 KB Ok
8 Correct 5 ms 6652 KB Ok
9 Correct 5 ms 6652 KB Ok
10 Correct 5 ms 6652 KB Ok
11 Correct 5 ms 6652 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6652 KB Ok
2 Correct 5 ms 6652 KB Ok
3 Correct 6 ms 6652 KB Ok
4 Correct 5 ms 6652 KB Ok
5 Correct 5 ms 6652 KB Ok
6 Correct 122 ms 19516 KB Ok
7 Correct 110 ms 25312 KB Ok
8 Correct 231 ms 28728 KB Ok
9 Correct 151 ms 28728 KB Ok
10 Correct 90 ms 28728 KB Ok
11 Correct 134 ms 28728 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Ok
2 Correct 5 ms 5088 KB Ok
3 Correct 5 ms 5160 KB Ok
4 Correct 5 ms 5232 KB Ok
5 Correct 6 ms 5232 KB Ok
6 Correct 6 ms 5232 KB Ok
7 Correct 6 ms 5232 KB Ok
8 Correct 5 ms 5232 KB Ok
9 Correct 6 ms 5232 KB Ok
10 Correct 5 ms 5232 KB Ok
11 Correct 6 ms 5296 KB Ok
12 Correct 24 ms 5296 KB Ok
13 Correct 5 ms 6652 KB Ok
14 Correct 6 ms 6652 KB Ok
15 Correct 5 ms 6652 KB Ok
16 Correct 5 ms 6652 KB Ok
17 Correct 5 ms 6652 KB Ok
18 Correct 5 ms 6652 KB Ok
19 Correct 5 ms 6652 KB Ok
20 Correct 5 ms 6652 KB Ok
21 Correct 5 ms 6652 KB Ok
22 Correct 5 ms 6652 KB Ok
23 Correct 5 ms 6652 KB Ok
24 Correct 8 ms 28728 KB Ok
25 Correct 7 ms 28728 KB Ok
26 Correct 9 ms 28728 KB Ok
27 Correct 7 ms 28728 KB Ok
28 Correct 7 ms 28728 KB Ok
29 Correct 7 ms 28728 KB Ok
30 Correct 7 ms 28728 KB Ok
31 Correct 8 ms 28728 KB Ok
32 Correct 8 ms 28728 KB Ok
33 Correct 7 ms 28728 KB Ok
34 Correct 11 ms 28728 KB Ok
35 Correct 10 ms 28728 KB Ok
36 Correct 11 ms 28728 KB Ok
37 Correct 11 ms 28728 KB Ok
38 Correct 10 ms 28728 KB Ok
39 Correct 10 ms 28728 KB Ok
40 Correct 11 ms 28728 KB Ok
41 Correct 11 ms 28728 KB Ok
42 Correct 11 ms 28728 KB Ok
43 Correct 10 ms 28728 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Ok
2 Correct 5 ms 5088 KB Ok
3 Correct 5 ms 5160 KB Ok
4 Correct 5 ms 5232 KB Ok
5 Correct 6 ms 5232 KB Ok
6 Correct 6 ms 5232 KB Ok
7 Correct 6 ms 5232 KB Ok
8 Correct 5 ms 5232 KB Ok
9 Correct 6 ms 5232 KB Ok
10 Correct 5 ms 5232 KB Ok
11 Correct 6 ms 5296 KB Ok
12 Correct 24 ms 5296 KB Ok
13 Correct 7 ms 5340 KB Ok
14 Correct 5 ms 5340 KB Ok
15 Correct 5 ms 5340 KB Ok
16 Correct 5 ms 5340 KB Ok
17 Correct 5 ms 5340 KB Ok
18 Correct 8 ms 5484 KB Ok
19 Correct 17 ms 6508 KB Ok
20 Correct 12 ms 6508 KB Ok
21 Correct 19 ms 6652 KB Ok
22 Correct 14 ms 6652 KB Ok
23 Correct 5 ms 6652 KB Ok
24 Correct 6 ms 6652 KB Ok
25 Correct 5 ms 6652 KB Ok
26 Correct 5 ms 6652 KB Ok
27 Correct 5 ms 6652 KB Ok
28 Correct 5 ms 6652 KB Ok
29 Correct 5 ms 6652 KB Ok
30 Correct 5 ms 6652 KB Ok
31 Correct 5 ms 6652 KB Ok
32 Correct 5 ms 6652 KB Ok
33 Correct 5 ms 6652 KB Ok
34 Correct 8 ms 28728 KB Ok
35 Correct 7 ms 28728 KB Ok
36 Correct 9 ms 28728 KB Ok
37 Correct 7 ms 28728 KB Ok
38 Correct 7 ms 28728 KB Ok
39 Correct 7 ms 28728 KB Ok
40 Correct 7 ms 28728 KB Ok
41 Correct 8 ms 28728 KB Ok
42 Correct 8 ms 28728 KB Ok
43 Correct 7 ms 28728 KB Ok
44 Correct 11 ms 28728 KB Ok
45 Correct 10 ms 28728 KB Ok
46 Correct 11 ms 28728 KB Ok
47 Correct 11 ms 28728 KB Ok
48 Correct 10 ms 28728 KB Ok
49 Correct 10 ms 28728 KB Ok
50 Correct 11 ms 28728 KB Ok
51 Correct 11 ms 28728 KB Ok
52 Correct 11 ms 28728 KB Ok
53 Correct 10 ms 28728 KB Ok
54 Correct 98 ms 28728 KB Ok
55 Correct 108 ms 28728 KB Ok
56 Correct 105 ms 28728 KB Ok
57 Correct 75 ms 28728 KB Ok
58 Correct 88 ms 28728 KB Ok
59 Correct 83 ms 28728 KB Ok
60 Correct 76 ms 28728 KB Ok
61 Correct 79 ms 28728 KB Ok
62 Correct 108 ms 28728 KB Ok
63 Correct 91 ms 28728 KB Ok
64 Correct 103 ms 28728 KB Ok
65 Correct 93 ms 28728 KB Ok
66 Correct 87 ms 28728 KB Ok
67 Correct 75 ms 28728 KB Ok
68 Correct 85 ms 28728 KB Ok
69 Correct 221 ms 28728 KB Ok
70 Correct 229 ms 28728 KB Ok
71 Correct 223 ms 28728 KB Ok
72 Correct 212 ms 28728 KB Ok
73 Correct 230 ms 28728 KB Ok
74 Correct 236 ms 28728 KB Ok
75 Correct 210 ms 28728 KB Ok
76 Correct 233 ms 28728 KB Ok
77 Correct 213 ms 28728 KB Ok
78 Correct 246 ms 28728 KB Ok
79 Correct 236 ms 28728 KB Ok
80 Correct 233 ms 28728 KB Ok
81 Correct 228 ms 28728 KB Ok
82 Correct 322 ms 28728 KB Ok
83 Correct 248 ms 28728 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Ok
2 Correct 5 ms 5088 KB Ok
3 Correct 5 ms 5160 KB Ok
4 Correct 5 ms 5232 KB Ok
5 Correct 6 ms 5232 KB Ok
6 Correct 6 ms 5232 KB Ok
7 Correct 6 ms 5232 KB Ok
8 Correct 5 ms 5232 KB Ok
9 Correct 6 ms 5232 KB Ok
10 Correct 5 ms 5232 KB Ok
11 Correct 6 ms 5296 KB Ok
12 Correct 24 ms 5296 KB Ok
13 Correct 7 ms 5340 KB Ok
14 Correct 5 ms 5340 KB Ok
15 Correct 5 ms 5340 KB Ok
16 Correct 5 ms 5340 KB Ok
17 Correct 5 ms 5340 KB Ok
18 Correct 8 ms 5484 KB Ok
19 Correct 17 ms 6508 KB Ok
20 Correct 12 ms 6508 KB Ok
21 Correct 19 ms 6652 KB Ok
22 Correct 14 ms 6652 KB Ok
23 Correct 5 ms 6652 KB Ok
24 Correct 6 ms 6652 KB Ok
25 Correct 5 ms 6652 KB Ok
26 Correct 5 ms 6652 KB Ok
27 Correct 5 ms 6652 KB Ok
28 Correct 5 ms 6652 KB Ok
29 Correct 5 ms 6652 KB Ok
30 Correct 5 ms 6652 KB Ok
31 Correct 5 ms 6652 KB Ok
32 Correct 5 ms 6652 KB Ok
33 Correct 5 ms 6652 KB Ok
34 Correct 5 ms 6652 KB Ok
35 Correct 5 ms 6652 KB Ok
36 Correct 6 ms 6652 KB Ok
37 Correct 5 ms 6652 KB Ok
38 Correct 5 ms 6652 KB Ok
39 Correct 122 ms 19516 KB Ok
40 Correct 110 ms 25312 KB Ok
41 Correct 231 ms 28728 KB Ok
42 Correct 151 ms 28728 KB Ok
43 Correct 90 ms 28728 KB Ok
44 Correct 134 ms 28728 KB Ok
45 Correct 8 ms 28728 KB Ok
46 Correct 7 ms 28728 KB Ok
47 Correct 9 ms 28728 KB Ok
48 Correct 7 ms 28728 KB Ok
49 Correct 7 ms 28728 KB Ok
50 Correct 7 ms 28728 KB Ok
51 Correct 7 ms 28728 KB Ok
52 Correct 8 ms 28728 KB Ok
53 Correct 8 ms 28728 KB Ok
54 Correct 7 ms 28728 KB Ok
55 Correct 11 ms 28728 KB Ok
56 Correct 10 ms 28728 KB Ok
57 Correct 11 ms 28728 KB Ok
58 Correct 11 ms 28728 KB Ok
59 Correct 10 ms 28728 KB Ok
60 Correct 10 ms 28728 KB Ok
61 Correct 11 ms 28728 KB Ok
62 Correct 11 ms 28728 KB Ok
63 Correct 11 ms 28728 KB Ok
64 Correct 10 ms 28728 KB Ok
65 Correct 98 ms 28728 KB Ok
66 Correct 108 ms 28728 KB Ok
67 Correct 105 ms 28728 KB Ok
68 Correct 75 ms 28728 KB Ok
69 Correct 88 ms 28728 KB Ok
70 Correct 83 ms 28728 KB Ok
71 Correct 76 ms 28728 KB Ok
72 Correct 79 ms 28728 KB Ok
73 Correct 108 ms 28728 KB Ok
74 Correct 91 ms 28728 KB Ok
75 Correct 103 ms 28728 KB Ok
76 Correct 93 ms 28728 KB Ok
77 Correct 87 ms 28728 KB Ok
78 Correct 75 ms 28728 KB Ok
79 Correct 85 ms 28728 KB Ok
80 Correct 221 ms 28728 KB Ok
81 Correct 229 ms 28728 KB Ok
82 Correct 223 ms 28728 KB Ok
83 Correct 212 ms 28728 KB Ok
84 Correct 230 ms 28728 KB Ok
85 Correct 236 ms 28728 KB Ok
86 Correct 210 ms 28728 KB Ok
87 Correct 233 ms 28728 KB Ok
88 Correct 213 ms 28728 KB Ok
89 Correct 246 ms 28728 KB Ok
90 Correct 236 ms 28728 KB Ok
91 Correct 233 ms 28728 KB Ok
92 Correct 228 ms 28728 KB Ok
93 Correct 322 ms 28728 KB Ok
94 Correct 248 ms 28728 KB Ok
95 Runtime error 112 ms 28728 KB Execution killed with signal 11 (could be triggered by violating memory limits)
96 Halted 0 ms 0 KB -