Submission #611609

# Submission time Handle Problem Language Result Execution time Memory
611609 2022-07-29T06:00:17 Z 조영욱(#8499) Segway (COI19_segway) C++17
100 / 100
743 ms 1480 KB
#include <bits/stdc++.h>
using namespace std;

int n;
int a[20000][3];
int m;
int ac[301];
int val[301];
typedef pair<int,int> P;
int pos[20000];
int ret[20000];
int en[20000];
int speed[20000];

int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        for(int j=0;j<3;j++) {
            scanf("%d",&a[i][j]);
        }
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++) {
        int x;
        scanf("%d",&x);
        ac[x]=1;
    }
    int pr=-1;
    vector<int> vec;
    priority_queue<P,vector<P>,greater<P>> pq;
    for(int i=0;i<n;i++) {
        pq.push(P(a[i][0],i));
        vec.push_back(0);
        speed[i]=a[i][0];
    }
    while (!pq.empty()) {
        P now=pq.top();
        pq.pop();
        if (now.first!=pr) {
            for(int i=0;i<vec.size();i++) {
                val[vec[i]]++;
            }
            vec.clear();
        }
        pr=now.first;
        pos[now.second]++;
        vec.push_back(pos[now.second]);
        int x=pos[now.second];
        if (x==300) {
            ret[now.second]=now.first;
            continue;
        }
        if (en[now.second]<=x) {
            if (ac[x]==1&&val[x]%20!=0) {
                speed[now.second]=1;
                en[now.second]=x+(val[x]%20);
            }
            else {
                if (x<100) {
                    speed[now.second]=a[now.second][0];
                }
                else if (x<200) {
                    speed[now.second]=a[now.second][1];
                }
                else {
                    speed[now.second]=a[now.second][2];
                }
            }
        }
        pq.push(P(now.first+speed[now.second],now.second));
    }
    for(int i=0;i<n;i++) {
        printf("%d\n",ret[i]);
    }
    return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             for(int i=0;i<vec.size();i++) {
      |                         ~^~~~~~~~~~~
segway.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
segway.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |             scanf("%d",&a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~
segway.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d",&m);
      |     ~~~~~^~~~~~~~~
segway.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 22 ms 356 KB Output is correct
4 Correct 88 ms 468 KB Output is correct
5 Correct 743 ms 1480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 2 ms 308 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
9 Correct 7 ms 340 KB Output is correct
10 Correct 9 ms 340 KB Output is correct
11 Correct 7 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 22 ms 356 KB Output is correct
4 Correct 88 ms 468 KB Output is correct
5 Correct 743 ms 1480 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 308 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 7 ms 340 KB Output is correct
15 Correct 9 ms 340 KB Output is correct
16 Correct 7 ms 340 KB Output is correct
17 Correct 32 ms 364 KB Output is correct
18 Correct 52 ms 408 KB Output is correct
19 Correct 294 ms 828 KB Output is correct
20 Correct 403 ms 932 KB Output is correct
21 Correct 518 ms 1112 KB Output is correct
22 Correct 636 ms 1376 KB Output is correct
23 Correct 584 ms 1372 KB Output is correct