제출 #583238

#제출 시각아이디문제언어결과실행 시간메모리
583238LucaIlie기지국 (IOI20_stations)C++17
100 / 100
1033 ms812 KiB
#include "stations.h" #include <bits/stdc++.h> #define MAX_N 1000 using namespace std; int l; int lc[MAX_N], rc[MAX_N]; vector<int> edges[MAX_N]; vector<int> labels, c; void dfs( int u, int p, int d ) { if ( d == 0 ) labels[u] = l / 2; l++; for ( int v: edges[u] ) { if ( v != p ) dfs( v, u, 1 - d ); } if ( d == 1 ) labels[u] = l / 2; l++; } vector<int> label( int n, int k, vector<int> u, vector<int> v ) { for ( int i = 0; i < n; i++ ) edges[i].clear(); for ( int i = 0; i < n - 1; i++ ) { edges[u[i]].push_back( v[i] ); edges[v[i]].push_back( u[i] ); } labels.resize( n ); l = 0; dfs( 0, -1, 0 ); return labels; } int find_next_station( int s, int t, vector<int> e ) { int ls, rs, ds, p, l, h, i; l = h = 0; for ( int x: e ) { if ( x < s ) l++; else h++; } ds = (l == 0 ? 0 : 1); s = s * 2; t = t * 2; p = 0; c.clear(); if ( ds == 0 ) { if ( s == 0 ) c = e; else { p = e.back(); for ( i = 0; i < e.size() - 1; i++ ) c.push_back( e[i] ); } ls = s; rs = c.back() * 2 + 1; for ( i = 0; i < c.size(); i++ ) rc[i] = c[i] * 2; lc[0] = ls + 1; for ( i = 1; i < c.size(); i++ ) lc[i] = rc[i - 1] + 1; } else { if ( s == 0 ) c = e; else { p = e.front(); for ( i = 1; i < e.size(); i++ ) c.push_back( e[i] ); } ls = c.front() * 2 - 1; rs = s; for ( i = 0; i < c.size(); i++ ) lc[i] = c[i] * 2; for ( i = 0; i + 1 < c.size(); i++ ) rc[i] = lc[i + 1] - 1; rc[c.size() - 1] = rs - 1; } for ( i = 0; i < c.size(); i++ ) { if ( lc[i] <= t && t <= rc[i] ) return c[i]; } return p; }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:62:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             for ( i = 0; i < e.size() - 1; i++ )
      |                          ~~^~~~~~~~~~~~~~
stations.cpp:67:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for ( i = 0; i < c.size(); i++ )
      |                      ~~^~~~~~~~~~
stations.cpp:70:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         for ( i = 1; i < c.size(); i++ )
      |                      ~~^~~~~~~~~~
stations.cpp:77:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |             for ( i = 1; i < e.size(); i++ )
      |                          ~~^~~~~~~~~~
stations.cpp:82:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |         for ( i = 0; i < c.size(); i++ )
      |                      ~~^~~~~~~~~~
stations.cpp:84:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for ( i = 0; i + 1 < c.size(); i++ )
      |                      ~~~~~~^~~~~~~~~~
stations.cpp:89:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |     for ( 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...