Submission #611607

# Submission time Handle Problem Language Result Execution time Memory
611607 2022-07-29T05:59:02 Z 조영욱(#8499) Segway (COI19_segway) C++17
0 / 100
1 ms 316 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();
        }
        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 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -