Submission #385633

# Submission time Handle Problem Language Result Execution time Memory
385633 2021-04-04T16:22:24 Z Ahmadsm2005 Stations (IOI20_stations) C++14
0 / 100
1043 ms 1000 KB
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
int C;
vector<vector<int>>edges;
vector<int>labels;
void DFS(int v,int u=-1){
labels[v]=C;
C++;
for(int i=0;i<edges[v].size();i++)
if(edges[v][i]!=u)
DFS(edges[v][i],v);
}
vector<int>label(int n,int k,vector<int>u,vector<int>v){
labels.clear();
labels.resize(n);
edges.resize(n);
for(int i=0;i<u.size();i++){
edges[u[i]].push_back(v[i]),edges[v[i]].push_back(u[i]);
}
DFS(0);
C=0;
edges.clear();
return labels;
}
int find_next_station(int s, int t,vector<int>c){
if(s<t){
int L=0,R=c.size()-1,mid,BEST=INT_MIN;
while(L<=R){
mid=(L+R)/2;
if(c[mid]<=t)
L=mid+1,BEST=max(BEST,mid);
else
R=mid-1;
}
return c[BEST];
}
return c[0];
}

Compilation message

stations.cpp: In function 'void DFS(int, int)':
stations.cpp:10:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | for(int i=0;i<edges[v].size();i++)
      |             ~^~~~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | for(int i=0;i<u.size();i++){
      |             ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 581 ms 884 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 535 ms 1000 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 610 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1043 ms 756 KB Output is correct
2 Correct 862 ms 756 KB Output is correct
3 Incorrect 677 ms 736 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 602 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -