제출 #1024414

#제출 시각아이디문제언어결과실행 시간메모리
1024414Ahmed_Solyman기지국 (IOI20_stations)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<int>>adj; vector<int>l,r,p,ret; int mark=0; void dfs(int node,int par,int dep){ if(dep)ret[node]=mark++; for(auto i:adj[node]) if(i!=par)dfs(i,node,1-dep); if(!dep)ret[node]=mark++; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ mark=0; l=r=p=ret=vector<int>(n); adj=vector<vector<int>>(n); for(int i=0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0,0,1); return ret; } int find_next_station(int s, int t,vector<int> c){ int m=(int)c.size(); for(int i=0;i<m;i++){ if(c[i]==t)return t; } if(s==0){ for(int i=m-1;i>=0;i--){ int in=(i==0?s+1:c[i-1]+1); int out=c[i]; if(t>=n && t<=out){ return c[i]; } } assert(0); } if(s<c[0]){///given is the in[s] int p=c[m-1]; for(int i=m-2;i>=0;i--){ int in=(i==0?s+1:c[i-1]+1); int out=c[i]; if(t>=in && t<=out){ return c[i]; } } return p; } else{///given is the out[s] int p=c[0]; for(int i=1;i<m;i++){ int in=c[i]; int out=(i==m-1?s-1:c[i+1]-1); if(t>=n && t<=ut){ return c[i]; } } return p; } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:35:19: error: 'n' was not declared in this scope; did you mean 'in'?
   35 |             if(t>=n && t<=out){
      |                   ^
      |                   in
stations.cpp:33:17: warning: unused variable 'in' [-Wunused-variable]
   33 |             int in=(i==0?s+1:c[i-1]+1);
      |                 ^~
stations.cpp:57:19: error: 'n' was not declared in this scope; did you mean 'in'?
   57 |             if(t>=n && t<=ut){
      |                   ^
      |                   in
stations.cpp:57:27: error: 'ut' was not declared in this scope; did you mean 'out'?
   57 |             if(t>=n && t<=ut){
      |                           ^~
      |                           out
stations.cpp:55:17: warning: unused variable 'in' [-Wunused-variable]
   55 |             int in=c[i];
      |                 ^~
stations.cpp:56:17: warning: unused variable 'out' [-Wunused-variable]
   56 |             int out=(i==m-1?s-1:c[i+1]-1);
      |                 ^~~