Submission #926948

#TimeUsernameProblemLanguageResultExecution timeMemory
926948ByeWorld기지국 (IOI20_stations)C++14
0 / 100
523 ms948 KiB
#include "stations.h" #include <vector> #include <bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; typedef pair<int,int> pii; typedef pair<pii,int> ipii; const int MAXN = 2e3+10; const int MAX = 1e3; int n, k; vector <int> adj[MAXN]; vector <int> lab; int chi[MAXN], val[MAXN], cnt; void dfs(int nw, int par){ // build val, tergantung dfs val[nw] = cnt++; for(auto nx : adj[nw]){ if(nx == par) continue; dfs(nx, nw); } } void bd(int nw, int par){ // build nx (child) for(int i=0; i<adj[nw].size(); i++){ if(i+1==adj[nw].size()) chi[adj[nw][i]] = 0; else { // ada nx nya chi[adj[nw][i]] = adj[nw][i+1]; // nx nya yg itu } } for(auto nx : adj[nw]){ if(nx == par) continue; bd(nx, nw); } } vector<int> label(int N, int K, vector<int> u, vector<int> v) { n = N; k = K; lab.clear(); lab.resize(n); cnt = 0; for(int i=0; i<=n; i++) adj[i].clear(); for(int i=0; i<n-1; i++){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(1, -1); bd(1, -1); for(int i=0; i<n; i++) lab[i] = val[i] + chi[i]*MAX; //for(int i=0; i<n; i++) cout << i << ' ' << lab[i] << " p\n"; return lab; } int find_next_station(int s, int t, vector<int> c) { // c sorted int ans = -1; if(s==0){ // s itu root for(auto in : c){ if(in <= t) ans = in; // ambil yg terakhir -> in <= } return ans; } int nx = s/MAX; // kalo nx==0, brati gk ada nx for(int i=1; i<c.size(); i++){ for(auto in : c){ if(in <= t) ans = in; // ambil yg terakhir -> in <= } } if(t < c[1] || t >= nx) return c[0]; // parent return ans; }

Compilation message (stderr)

stations.cpp: In function 'void bd(int, int)':
stations.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i=0; i<adj[nw].size(); i++){
      |               ~^~~~~~~~~~~~~~~
stations.cpp:27:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   if(i+1==adj[nw].size()) chi[adj[nw][i]] = 0;
      |      ~~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:66:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |  for(int i=1; i<c.size(); i++){
      |               ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...