Submission #102588

# Submission time Handle Problem Language Result Execution time Memory
102588 2019-03-26T03:33:08 Z username Highway Tolls (IOI18_highway) C++14
0 / 100
345 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,n)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,n)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;
  ^~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6568 KB Output is correct
2 Correct 7 ms 6668 KB Output is correct
3 Runtime error 17 ms 13332 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6688 KB Output is correct
2 Correct 28 ms 7516 KB Output is correct
3 Correct 229 ms 13860 KB Output is correct
4 Correct 231 ms 13864 KB Output is correct
5 Correct 241 ms 13852 KB Output is correct
6 Correct 217 ms 13836 KB Output is correct
7 Correct 206 ms 13844 KB Output is correct
8 Correct 213 ms 13844 KB Output is correct
9 Correct 227 ms 13852 KB Output is correct
10 Correct 241 ms 13888 KB Output is correct
11 Correct 258 ms 13264 KB Output is correct
12 Correct 257 ms 13460 KB Output is correct
13 Correct 240 ms 13252 KB Output is correct
14 Incorrect 213 ms 13304 KB Output is incorrect: {s, t} is wrong.
# Verdict Execution time Memory Grader output
1 Correct 27 ms 7416 KB Output is correct
2 Correct 47 ms 8152 KB Output is correct
3 Correct 58 ms 8868 KB Output is correct
4 Correct 182 ms 13184 KB Output is correct
5 Correct 162 ms 13260 KB Output is correct
6 Correct 178 ms 13536 KB Output is correct
7 Correct 177 ms 13232 KB Output is correct
8 Correct 201 ms 13140 KB Output is correct
9 Incorrect 190 ms 13224 KB Output is incorrect: {s, t} is wrong.
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6648 KB Output is correct
2 Correct 31 ms 7464 KB Output is correct
3 Correct 168 ms 12332 KB Output is correct
4 Correct 234 ms 13828 KB Output is correct
5 Correct 234 ms 13852 KB Output is correct
6 Correct 221 ms 13860 KB Output is correct
7 Correct 243 ms 13872 KB Output is correct
8 Correct 213 ms 13952 KB Output is correct
9 Incorrect 235 ms 13792 KB Output is incorrect: {s, t} is wrong.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 7464 KB Output is correct
2 Correct 32 ms 7612 KB Output is correct
3 Correct 260 ms 14180 KB Output is correct
4 Correct 293 ms 14644 KB Output is correct
5 Correct 327 ms 15620 KB Output is correct
6 Correct 345 ms 15616 KB Output is correct
7 Correct 313 ms 15620 KB Output is correct
8 Correct 314 ms 15416 KB Output is correct
9 Correct 239 ms 12876 KB Output is correct
10 Incorrect 241 ms 13376 KB Output is incorrect: {s, t} is wrong.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 7464 KB Output is correct
2 Correct 26 ms 7584 KB Output is correct
3 Correct 254 ms 14128 KB Output is correct
4 Correct 278 ms 14504 KB Output is correct
5 Correct 284 ms 14664 KB Output is correct
6 Correct 338 ms 15592 KB Output is correct
7 Correct 248 ms 14204 KB Output is correct
8 Correct 268 ms 14388 KB Output is correct
9 Correct 273 ms 14600 KB Output is correct
10 Correct 343 ms 15616 KB Output is correct
11 Correct 304 ms 15616 KB Output is correct
12 Correct 333 ms 15632 KB Output is correct
13 Incorrect 259 ms 13908 KB Output is incorrect: {s, t} is wrong.
14 Halted 0 ms 0 KB -