Submission #117695

# Submission time Handle Problem Language Result Execution time Memory
117695 2019-06-17T06:42:58 Z 이온조(#2879) Segway (COI19_segway) C++14
100 / 100
88 ms 6540 KB
#include <bits/stdc++.h>
using namespace std;

int cnt[333];
int a[20009], b[20009], c[20009], l[20009], p[20009], ans[20009];
bool chk[333];
vector<int> ev[55]; int MOD = 55, now = 0;

int main() {
    int N; scanf("%d",&N);
    for(int i=1; i<=N; i++) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        ev[a[i]].push_back(i);
    }
    int M; scanf("%d",&M);
    while(M--) {
        int foo; scanf("%d", &foo);
        chk[foo] = 1;
    }
    while(cnt[300] < N) {
        ++now;
        for(auto& it: ev[now % MOD]) {
            ++p[it];
            if(chk[p[it]] && !l[it]) l[it] = cnt[p[it]] % 20;

            if(p[it] == 300) ans[it] = now;
            else if(l[it]) {
                --l[it];
                ev[(now + 1) % MOD].push_back(it);
            }
            else {
                int nxt;
                if(p[it] < 100) nxt = (now + a[it]) % MOD;
                else if(p[it] < 200) nxt = (now + b[it]) % MOD;
                else nxt = (now + c[it]) % MOD;
                ev[nxt].push_back(it);
            }
        }
        for(auto& it: ev[now % MOD]) ++cnt[p[it]];
        ev[now % MOD].clear();
    }
    for(int i=1; i<=N; i++) printf("%d\n", ans[i]);
    return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N; scanf("%d",&N);
            ~~~~~^~~~~~~~~
segway.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &a[i], &b[i], &c[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:15:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int M; scanf("%d",&M);
            ~~~~~^~~~~~~~~
segway.cpp:17:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int foo; scanf("%d", &foo);
                  ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 13 ms 640 KB Output is correct
5 Correct 88 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 356 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 13 ms 640 KB Output is correct
5 Correct 88 ms 2676 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 356 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 9 ms 908 KB Output is correct
19 Correct 35 ms 1768 KB Output is correct
20 Correct 43 ms 1784 KB Output is correct
21 Correct 62 ms 2668 KB Output is correct
22 Correct 77 ms 4140 KB Output is correct
23 Correct 75 ms 6540 KB Output is correct