답안 #537675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537675 2022-03-15T11:14:46 Z groshi 기지국 (IOI20_stations) C++17
0 / 100
1 ms 432 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<stations.h>
using namespace std;
int kiedy=1;
struct wi{
    vector<int> Q;
    int odw=0;
}*w;
void dfs(int x)
{
    w[x].odw=kiedy;
    kiedy++;
    for(int i=0;i<w[x].Q.size();i++)
    {
        int pom=w[x].Q[i];
        if(w[pom].odw!=0)
            continue;
        dfs(pom);
    }
}
vector<int> label(int n,int k,vector<int> u,vector<int> v)
{
    kiedy=1;
    for(int i=1;i<=n;i++)
    {
        w[i].Q.clear();
        w[i].odw=0;
    }
    for(int i=0;i<u.size();i++)
    {
        u[i]++;
        v[i]++;
        w[u[i]].Q.push_back(v[i]);
        w[v[i]].Q.push_back(u[i]);
    }
    dfs(1);
    vector<int> wypisz;
    for(int i=1;i<=n;i++)
        wypisz.push_back(w[i].odw);
}
int find_next_station(int s,int t,vector<int> c)
{
    for(int i=0;i<c.size();i++)
        if(c[i]==t)
            return c[i];
    if(c[0]>0)
    {
        if(t<s || t>c[c.size()-2])
            return c[c.size()-1];
        else return *lower_bound(c.begin(),c.end(),t);
    }
    else if(t<c[0] || t>s)
        return c[0];
    else return *(lower_bound(c.begin(),c.end(),t)-1);
}

Compilation message

stations.cpp: In function 'void dfs(int)':
stations.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0;i<w[x].Q.size();i++)
      |                 ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<u.size();i++)
      |                 ~^~~~~~~~~
stations.cpp:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=0;i<c.size();i++)
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -