답안 #311965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
311965 2020-10-12T05:10:52 Z htc001 기지국 (IOI20_stations) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;

const int N=1005;
int tme,m;
vector<int> lab;
vector<int> nei[N];
map<int,int> mp;

void dfs(int x,int p,int lv){
	++tme;
	if(lv){
		lab[x-1]=tme;
		mp[tme];
	}
	for(int i=0;i<int(nei[x].size());i++){
		int to=nei[x][i];
		if(to!=p) dfs(to,x,lv^1);
	}
	++tme;
	if(!lv){
		lab[x-1]=tme;
		mp[tme];
	}
}

vector<int> label(int n,int k,vector<int> u,vector<int> v){
	mp.clear();
	lab.clear();
	lab.resize(n);
	tme=0;m=0;
	for(int i=1;i<=n;i++) nei[i].clear();
	for(int i=0;i<n-1;i++){
		u[i]++;v[i]++;
//		printf("%d %d\n",u[i],v[i]);
		nei[u[i]].push_back(v[i]);
		nei[v[i]].push_back(u[i]);
	}
	dfs(1,-1,0);
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++) it->second=m++;
	for(int i=0;i<n;i++) lab[i]=mp[lab[i]];
	return lab;
}

int find_next_station(int s,int t,vector<int> c){
	sort(c.begin(),c.end());
	assert(s<c[0]||s>c[int(c.size())-1]]);
	if(s<c[0]){
		if(t>s) return *lower_bound(c.begin(),c.end(),t);
		else return c[int(c.size())-1];
	}else{
		if(t<s) return *(lower_bound(c.begin(),c.end(),t+1)-1);
		else return c[0];
	}
}

Compilation message

In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from stations.cpp:1:
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:48:37: error: expected ')' before ']' token
   48 |  assert(s<c[0]||s>c[int(c.size())-1]]);
      |                                     ^
stations.cpp:48:2: note: to match this '('
   48 |  assert(s<c[0]||s>c[int(c.size())-1]]);
      |  ^~~~~~
stations.cpp:48:39: error: expected ')' before ';' token
   48 |  assert(s<c[0]||s>c[int(c.size())-1]]);
      |                                       ^
In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from stations.cpp:1:
stations.cpp:48:2: note: to match this '('
   48 |  assert(s<c[0]||s>c[int(c.size())-1]]);
      |  ^~~~~~