# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
432792 |
2021-06-18T13:24:18 Z |
Hazem |
Stations (IOI20_stations) |
C++14 |
|
835 ms |
656 KB |
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3;
int cnt = 0;
int dfs(int i,int pre,vector<int> &ret,vector<int> adj[]){
int mx = cnt;
ret[i] = cnt++;
for(int j=0;j<adj[i].size();j++){
int v = adj[i][j];
if(v==pre)continue;
mx = max(mx,dfs(v,i,ret,adj));
}
//ret[i] += mx*1000;
return mx;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
cnt = 0;
vector<int>adj[N];
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
vector<int> ret = vector<int>(n,0);
dfs(0,0,ret,adj);
return ret;
}
int get_val(int x,int l,int r){
int ret = 0;
return x%1000;
for(int i=l;i<=r;i++)
ret |= (1<<(i-l))*(((1<<i)&x)>0);
return ret;
}
bool cmp(int x,int y){
return get_val(x,0,9)<get_val(y,0,9);
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s<t)
return s+1;
else
return s-1;
}
Compilation message
stations.cpp: In function 'int dfs(int, int, std::vector<int>&, std::vector<int>*)':
stations.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int j=0;j<adj[i].size();j++){
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
583 ms |
616 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
447 ms |
492 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
554 ms |
656 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
835 ms |
480 KB |
Output is correct |
2 |
Incorrect |
653 ms |
616 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
506 ms |
656 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |