답안 #671252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671252 2022-12-12T14:37:01 Z groshi 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
507 ms 67236 KB
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
struct wi{
    vector<int> Q;
    int odw=0;
    int ktory=0;
}*w;
int travel_plan(int n,int m,int R[][2],int L[],int k,int P[])
{
    w=new wi[n+3];
    for(int i=0;i<m;i++)
    {
        int x=R[i][0];
        int y=R[i][1];
        int z=L[i];
        cin>>x>>y>>z;
        w[x].Q.push_back(y);
        w[x].Q.push_back(z);
        w[y].Q.push_back(x);
        w[y].Q.push_back(z);
    }
    priority_queue<pair<int,int> > kolejka;
    for(int i=0;i<k;i++)
    {
        int x=P[i];
        w[x].odw=1;
        for(int j=0;j<w[x].Q.size();j+=2)
        {
            int pom=w[x].Q[j];
            kolejka.push({-w[x].Q[j+1],pom});
        }
    }
    while(!kolejka.empty())
    {
        auto para=kolejka.top();
        kolejka.pop();
        if(w[para.second].odw)
            continue;
        w[para.second].ktory++;
        if(w[para.second].ktory==2)
        {
            if(para.second==0)
                return -para.first;
            w[para.second].odw=1;
            for(int i=0;i<w[para.second].Q.size();i+=2)
            {
                int pom=w[para.second].Q[i];
                if(w[pom].odw)
                    continue;
                kolejka.push({para.first-w[para.second].Q[i+1],pom});
            }
        }
    }
    return -1;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int j=0;j<w[x].Q.size();j+=2)
      |                     ~^~~~~~~~~~~~~~
crocodile.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(int i=0;i<w[para.second].Q.size();i+=2)
      |                         ~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 4 ms 980 KB Output is correct
13 Correct 4 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 4 ms 980 KB Output is correct
13 Correct 4 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 460 ms 63036 KB Output is correct
17 Correct 75 ms 13644 KB Output is correct
18 Correct 92 ms 15380 KB Output is correct
19 Correct 507 ms 67236 KB Output is correct
20 Correct 303 ms 55476 KB Output is correct
21 Correct 38 ms 5940 KB Output is correct
22 Correct 385 ms 44848 KB Output is correct