제출 #831346

#제출 시각아이디문제언어결과실행 시간메모리
831346Trumling기지국 (IOI20_stations)C++14
컴파일 에러
0 ms0 KiB
#include "stations.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define F first #define S second #define all(x) x.begin(),x.end() typedef long long ll; #define pb push_back #define INF 9999999999999999 vector<vector<int>>g; vector<int> label(int n, int k, vector<int> u, vector<int> v) { g.assign(n,vector<int>()); vector<bool>cnt(n,0); for (int i = 0; i < n-1; i++) { g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); if(g[u[i]].size()==2) cnt[u[i]]=1; if(g[v[i]].size()==2) cnt[v[i]]=1; } vector<int>labels(N); for(int i=0;i<n;i++) if(cnt[i]) { ll start=i,pre=i; ll idx=0; while(true) { label[start]=idx++; bool tf=0; for(auto x:g[start]) if(x!=pre) { tf=1; swap(start,pre); start=x; break; } if(!tf) break; } break; } return labels; } int find_next_station(int s, int t, vector<int> c) { ll l=-1,r=INF; if(c.size()==1) { if(c[0]<s) l=c[0]; else r=c[0]; } else { l=min(c[0],c[1]); r=max(c[0],c[1]); } if(t>s) return r; else return l; }

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

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:27:20: error: 'N' was not declared in this scope
   27 |  vector<int>labels(N);
      |                    ^
stations.cpp:37:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   37 |    label[start]=idx++;
      |               ^
stations.cpp:37:16: error: assignment of read-only location '*(label + ((sizetype)start))'
   37 |    label[start]=idx++;
      |    ~~~~~~~~~~~~^~~~~~