답안 #102593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102593 2019-03-26T04:36:31 Z username 통행료 (IOI18_highway) C++14
23 / 100
356 ms 15632 KB
#include<bits/stdc++.h>
#include "highway.h"
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define mid (l+r>>1)


const int maxn=9e4+9,inf=1<<30;
int n,m,o,d1[maxn],d2[maxn],p1[maxn],p2[maxn];
vector<pii>G[maxn];
VI g1[maxn],g2[maxn],w;
queue<int>Q;

void bfs(int s,int*dis,int*par){
	fill(dis,dis+n,inf);
	dis[s]=0;
	Q.push(s);
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		REP(i,0,G[u].size()){
			int v=G[u][i].first;
			if(dis[v]>dis[u]+1){
				dis[v]=dis[u]+1;
				par[v]=G[u][i].second;
				Q.push(v);
			}
		}
	}
}

int find(VI&vt,int*par){
	int l=0,r=vt.size();
	while(l+1<r){
		REP(i,1,mid)w[par[vt[i]]]=0;
		REP(i,mid,vt.size())w[par[vt[i]]]=1;
		if(ask(w)>o)l=mid;
		else r=mid;
	}
	return vt[l];
}

void find_pair(int _n,VI uu,VI vv,int a,int b){
	n=_n;
	m=uu.size();
	w.resize(m);
	o=ask(w);
	int l=0,r=m;
	while(l+1<r){
		REP(i,0,mid)w[i]=1;
		REP(i,mid,m)w[i]=0;
		if(ask(w)>o)r=mid;
		else l=mid;
	}
	int ee=r-1;
	REP(i,0,m){
		int u=uu[i],v=vv[i];
		G[u].pb(pii(v,i)),G[v].pb(pii(u,i));
	}
	bfs(uu[ee],d1,p1);
	bfs(vv[ee],d2,p2);
	VI v1,v2;
	REP(i,0,n){
		if(d1[i]<d2[i])v1.pb(i);
		else v2.pb(i);
	}
	sort(ALL(v1),[](int x,int y){return d1[x]<d1[y];});
	sort(ALL(v2),[](int x,int y){return d2[x]<d2[y];});
	REP(i,0,m)w[i]=1;
	w[ee]=0;
	REP(i,0,v1.size())w[p1[v1[i]]]=0;
	REP(i,0,v2.size())w[p2[v2[i]]]=0;
	int u=find(v1,p1);
	REP(i,0,m)w[i]=1;
	w[ee]=0;
	REP(i,0,v1.size())w[p1[v1[i]]]=0;
	REP(i,0,v2.size())w[p2[v2[i]]]=0;
	int v=find(v2,p2);
	answer(u,v);
}

Compilation message

highway.cpp: In function 'void bfs(int, int*, int*)':
highway.cpp:6:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                            ^
highway.cpp:26:3: note: in expansion of macro 'REP'
   REP(i,0,G[u].size()){
   ^~~
highway.cpp: In function 'int find(VI&, int*)':
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:6:46: note: in definition of macro 'REP'
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                              ^
highway.cpp:40:11: note: in expansion of macro 'mid'
   REP(i,1,mid)w[par[vt[i]]]=0;
           ^~~
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:6:40: note: in definition of macro 'REP'
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                        ^
highway.cpp:41:9: note: in expansion of macro 'mid'
   REP(i,mid,vt.size())w[par[vt[i]]]=1;
         ^~~
highway.cpp:6:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                            ^
highway.cpp:41:3: note: in expansion of macro 'REP'
   REP(i,mid,vt.size())w[par[vt[i]]]=1;
   ^~~
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:42:17: note: in expansion of macro 'mid'
   if(ask(w)>o)l=mid;
                 ^~~
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:43:10: note: in expansion of macro 'mid'
   else r=mid;
          ^~~
highway.cpp: In function 'void find_pair(int, VI, VI, int, int)':
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:6:46: note: in definition of macro 'REP'
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                              ^
highway.cpp:55:11: note: in expansion of macro 'mid'
   REP(i,0,mid)w[i]=1;
           ^~~
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:6:40: note: in definition of macro 'REP'
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                        ^
highway.cpp:56:9: note: in expansion of macro 'mid'
   REP(i,mid,m)w[i]=0;
         ^~~
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:57:17: note: in expansion of macro 'mid'
   if(ask(w)>o)r=mid;
                 ^~~
highway.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
highway.cpp:58:10: note: in expansion of macro 'mid'
   else l=mid;
          ^~~
highway.cpp:6:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                            ^
highway.cpp:76:2: note: in expansion of macro 'REP'
  REP(i,0,v1.size())w[p1[v1[i]]]=0;
  ^~~
highway.cpp:6:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                            ^
highway.cpp:77:2: note: in expansion of macro 'REP'
  REP(i,0,v2.size())w[p2[v2[i]]]=0;
  ^~~
highway.cpp:6:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                            ^
highway.cpp:81:2: note: in expansion of macro 'REP'
  REP(i,0,v1.size())w[p1[v1[i]]]=0;
  ^~~
highway.cpp:6:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(register int i=(j);i<(k);++i)
                                            ^
highway.cpp:82:2: note: in expansion of macro 'REP'
  REP(i,0,v2.size())w[p2[v2[i]]]=0;
  ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6648 KB Output is correct
2 Correct 8 ms 6648 KB Output is correct
3 Correct 8 ms 6668 KB Output is correct
4 Correct 7 ms 6672 KB Output is correct
5 Correct 8 ms 6648 KB Output is correct
6 Correct 8 ms 6648 KB Output is correct
7 Correct 8 ms 6748 KB Output is correct
8 Correct 8 ms 6648 KB Output is correct
9 Correct 7 ms 6752 KB Output is correct
10 Correct 7 ms 6740 KB Output is correct
11 Correct 8 ms 6648 KB Output is correct
12 Correct 8 ms 6676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6684 KB Output is correct
2 Correct 22 ms 7628 KB Output is correct
3 Correct 231 ms 13848 KB Output is correct
4 Correct 232 ms 13844 KB Output is correct
5 Correct 240 ms 13844 KB Output is correct
6 Correct 236 ms 13832 KB Output is correct
7 Correct 237 ms 13852 KB Output is correct
8 Correct 230 ms 13856 KB Output is correct
9 Correct 217 ms 13848 KB Output is correct
10 Correct 238 ms 13848 KB Output is correct
11 Correct 276 ms 13392 KB Output is correct
12 Correct 256 ms 13424 KB Output is correct
13 Correct 257 ms 13300 KB Output is correct
14 Incorrect 257 ms 13304 KB Output is incorrect: {s, t} is wrong.
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 7416 KB Output is correct
2 Correct 46 ms 8184 KB Output is correct
3 Correct 56 ms 8912 KB Output is correct
4 Correct 165 ms 13200 KB Output is correct
5 Correct 169 ms 13152 KB Output is correct
6 Correct 158 ms 13276 KB Output is correct
7 Correct 184 ms 13216 KB Output is correct
8 Correct 187 ms 13144 KB Output is correct
9 Incorrect 166 ms 13188 KB Output is incorrect: {s, t} is wrong.
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6776 KB Output is correct
2 Correct 31 ms 7416 KB Output is correct
3 Correct 176 ms 12344 KB Output is correct
4 Correct 225 ms 13828 KB Output is correct
5 Correct 218 ms 13876 KB Output is correct
6 Correct 228 ms 13820 KB Output is correct
7 Correct 214 ms 13800 KB Output is correct
8 Correct 227 ms 13808 KB Output is correct
9 Incorrect 215 ms 13844 KB Output is incorrect: {s, t} is wrong.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 7604 KB Output is correct
2 Correct 34 ms 7584 KB Output is correct
3 Correct 292 ms 14148 KB Output is correct
4 Correct 306 ms 14572 KB Output is correct
5 Correct 343 ms 15508 KB Output is correct
6 Correct 321 ms 15544 KB Output is correct
7 Correct 353 ms 15548 KB Output is correct
8 Correct 345 ms 15508 KB Output is correct
9 Correct 242 ms 12912 KB Output is correct
10 Correct 211 ms 13312 KB Output is correct
11 Correct 253 ms 13792 KB Output is correct
12 Correct 307 ms 14960 KB Output is correct
13 Correct 328 ms 15320 KB Output is correct
14 Correct 338 ms 15496 KB Output is correct
15 Correct 333 ms 15500 KB Output is correct
16 Correct 259 ms 13920 KB Output is correct
17 Correct 203 ms 14280 KB Output is correct
18 Correct 208 ms 14480 KB Output is correct
19 Correct 213 ms 14416 KB Output is correct
20 Correct 213 ms 14468 KB Output is correct
21 Correct 356 ms 15596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 7416 KB Output is correct
2 Correct 31 ms 7584 KB Output is correct
3 Correct 263 ms 14236 KB Output is correct
4 Correct 287 ms 14508 KB Output is correct
5 Correct 262 ms 14664 KB Output is correct
6 Correct 334 ms 15536 KB Output is correct
7 Correct 232 ms 14208 KB Output is correct
8 Correct 243 ms 14440 KB Output is correct
9 Correct 293 ms 14588 KB Output is correct
10 Correct 321 ms 15632 KB Output is correct
11 Correct 315 ms 15628 KB Output is correct
12 Correct 329 ms 15596 KB Output is correct
13 Correct 243 ms 13784 KB Output is correct
14 Correct 246 ms 13324 KB Output is correct
15 Correct 245 ms 13872 KB Output is correct
16 Correct 251 ms 13312 KB Output is correct
17 Correct 269 ms 13808 KB Output is correct
18 Correct 222 ms 13392 KB Output is correct
19 Correct 304 ms 15048 KB Output is correct
20 Correct 327 ms 15224 KB Output is correct
21 Correct 325 ms 15548 KB Output is correct
22 Correct 335 ms 15492 KB Output is correct
23 Correct 345 ms 15600 KB Output is correct
24 Correct 315 ms 15580 KB Output is correct
25 Correct 292 ms 15628 KB Output is correct
26 Correct 309 ms 15616 KB Output is correct
27 Correct 212 ms 14384 KB Output is correct
28 Correct 219 ms 14248 KB Output is correct
29 Correct 181 ms 14456 KB Output is correct
30 Incorrect 204 ms 14388 KB Output is incorrect: {s, t} is wrong.
31 Halted 0 ms 0 KB -