제출 #683690

#제출 시각아이디문제언어결과실행 시간메모리
683690sharaelong기지국 (IOI20_stations)C++17
52.32 / 100
1049 ms760 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int MAX_N = 1000; vector<int> adj[MAX_N]; int tour_cnt = 0; pii tour[MAX_N]; void dfs(int here, int parent = -1) { tour[here].first = tour_cnt++; for (int there: adj[here]) { if (there != parent) { dfs(there, here); } } tour[here].second = tour_cnt-1; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i=0; i<n; ++i) adj[i].clear(); tour_cnt = 0; for (int i=0; i<n-1; ++i) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0); assert(tour_cnt == n); const int MAX_N = 1000; vector<int> labels(n); for (int i=0; i<n; i++) labels[i] = tour[i].first * MAX_N + tour[i].second; // for (int i=0; i<n; ++i) cout << tour[i].first << ' ' << tour[i].second << endl; return labels; } int find_next_station(int s, int t, vector<int> c) { const int MAX_N = 1000; for (int i=0; i<c.size(); ++i) { if (c[i] < s) { assert(i == 0); continue; } int x = c[i] / MAX_N, y = c[i] % MAX_N; if (x <= t / MAX_N && t % MAX_N <= y) return c[i]; } return c[0]; }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i=0; 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...