제출 #926741

#제출 시각아이디문제언어결과실행 시간메모리
926741ByeWorld기지국 (IOI20_stations)C++14
16 / 100
614 ms1292 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; void dfs(int nw, int par, int val){ lab[nw] = val; for(auto nx : adj[nw]){ if(nx == par) continue; dfs(nx, nw, val+1); } } vector<int> label(int N, int K, vector<int> u, vector<int> v) { n = N; k = K; lab.clear(); lab.resize(n); 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]); } bool b = 0; for(int i=0; i<n; i++){ if(adj[i].size() > 2){ lab[i] = 0; // pivot for(int j=0; j<adj[i].size(); j++){ dfs(adj[i][j], i, j*MAX+1); } b = 1; } } if(!b){ // line lab[0] = 0; for(int j=0; j<adj[0].size(); j++){ dfs(adj[0][j], 0, j*MAX+1); } } //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) { int cs = s/MAX, ct = t/MAX; if(s==0){ return ct*MAX+1; // ke bagiannya t } if(cs == ct){ if(s < t){ // s ... t return s+1; } } int ans = s-1; if((ans % MAX) == 0) return 0; return ans; }

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for(int j=0; j<adj[i].size(); j++){
      |                 ~^~~~~~~~~~~~~~
stations.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for(int j=0; j<adj[0].size(); j++){
      |                ~^~~~~~~~~~~~~~
#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...