Submission #372483

# Submission time Handle Problem Language Result Execution time Memory
372483 2021-02-28T10:34:44 Z denkendoemeer Highway Tolls (IOI18_highway) C++14
100 / 100
300 ms 11460 KB
#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
int n,m,q[150005],h,ta,t[150005],viz[150005],p[150005],v2[150005];
vector<int>g,v3[150005];
void find_pair(int n2,vector<int>u,vector<int>v,int a,int b){
    int i;
    n=n2;
    m=u.size();
    g.resize(m);
    for(i=0;i<m;i++) {
        g[i]=0;
        v3[u[i]].push_back(v[i]);
        v3[v[i]].push_back(u[i]);
        }
    long long l=ask(g);
    int st=0,dr=n-2,mij,r=n-1;
    while(st<=dr){
        mij=(st+dr)/2;
        if (dr-st>60000)
            mij=60000;
        for(i=0;i<m;i++){
            if (u[i]>mij || v[i]>mij)
                g[i]=1;
            else
                g[i]=0;
        }
        if (ask(g)==l)
            r=mij,dr=mij-1;
        else
            st=mij+1;
    }
	int root=r;
	q[++ta]=root;
	viz[root]=1;
	t[root]=-1;
	while(h<ta){
		int x=q[++h];
		for(auto it:v3[x]){
			if (!viz[it]){
				viz[it]=1;
				q[++ta]=it;
				t[it]=x;
			}
		}
	}
	for(i=0;i<m;i++){
		if (t[u[i]]==v[i])
            p[u[i]]=i;
		if (t[v[i]]==u[i])
            p[v[i]]=i;
	}
	st=1;
	dr=ta-1;
	r=ta;
	while(st<=dr){
		mij=(st+dr)/2;
		if (dr-st>60000)
            mij=60000;
		for(i=0;i<m;i++)
            g[i]=1;
		for(i=2;i<=mij;i++)
            g[p[q[i]]]=0;
		if (ask(g)==l)
            r=mij,dr=mij-1;
		else
            st=mij+1;
	}
	int rb=q[r];
	int tp=rb;
	while(tp!=root){
		v2[p[tp]]=1;
		tp=t[tp];
	}
	st=1;
	dr=r-1;
	while(st<=dr){
		mij=(st+dr)/2;
		for(i=0;i<m;i++){
			if (!v2[i])
                g[i]=1;
			else
                g[i]=0;
		}
		for(i=2;i<=mij;i++)
            g[p[q[i]]]=0;
		if (ask(g)==l)
            r=mij,dr=mij-1;
		else
            st=mij+1;
	}
	int ra=q[r];
	answer(ra,rb);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3820 KB Output is correct
2 Correct 3 ms 3820 KB Output is correct
3 Correct 3 ms 3820 KB Output is correct
4 Correct 3 ms 3820 KB Output is correct
5 Correct 3 ms 3820 KB Output is correct
6 Correct 3 ms 3820 KB Output is correct
7 Correct 4 ms 3916 KB Output is correct
8 Correct 3 ms 3820 KB Output is correct
9 Correct 3 ms 3820 KB Output is correct
10 Correct 3 ms 3820 KB Output is correct
11 Correct 3 ms 3820 KB Output is correct
12 Correct 3 ms 3916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3948 KB Output is correct
2 Correct 17 ms 4716 KB Output is correct
3 Correct 173 ms 10284 KB Output is correct
4 Correct 180 ms 10084 KB Output is correct
5 Correct 168 ms 10204 KB Output is correct
6 Correct 162 ms 10220 KB Output is correct
7 Correct 163 ms 10080 KB Output is correct
8 Correct 160 ms 10168 KB Output is correct
9 Correct 146 ms 10084 KB Output is correct
10 Correct 169 ms 10140 KB Output is correct
11 Correct 154 ms 10388 KB Output is correct
12 Correct 149 ms 10400 KB Output is correct
13 Correct 156 ms 10280 KB Output is correct
14 Correct 169 ms 10288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 4588 KB Output is correct
2 Correct 29 ms 5208 KB Output is correct
3 Correct 40 ms 5932 KB Output is correct
4 Correct 94 ms 9992 KB Output is correct
5 Correct 147 ms 9940 KB Output is correct
6 Correct 125 ms 10152 KB Output is correct
7 Correct 108 ms 10048 KB Output is correct
8 Correct 120 ms 10292 KB Output is correct
9 Correct 114 ms 9940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3964 KB Output is correct
2 Correct 19 ms 4588 KB Output is correct
3 Correct 106 ms 8692 KB Output is correct
4 Correct 149 ms 10092 KB Output is correct
5 Correct 147 ms 10160 KB Output is correct
6 Correct 144 ms 10060 KB Output is correct
7 Correct 143 ms 10044 KB Output is correct
8 Correct 138 ms 10052 KB Output is correct
9 Correct 171 ms 10224 KB Output is correct
10 Correct 155 ms 10200 KB Output is correct
11 Correct 185 ms 10292 KB Output is correct
12 Correct 177 ms 10344 KB Output is correct
13 Correct 176 ms 10304 KB Output is correct
14 Correct 174 ms 10340 KB Output is correct
15 Correct 150 ms 10136 KB Output is correct
16 Correct 151 ms 10036 KB Output is correct
17 Correct 182 ms 10284 KB Output is correct
18 Correct 190 ms 10532 KB Output is correct
19 Correct 147 ms 10080 KB Output is correct
20 Correct 141 ms 10408 KB Output is correct
21 Correct 145 ms 10480 KB Output is correct
22 Correct 144 ms 10292 KB Output is correct
23 Correct 156 ms 10636 KB Output is correct
24 Correct 163 ms 10660 KB Output is correct
25 Correct 185 ms 10572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 4588 KB Output is correct
2 Correct 22 ms 4588 KB Output is correct
3 Correct 179 ms 10296 KB Output is correct
4 Correct 200 ms 10528 KB Output is correct
5 Correct 236 ms 11124 KB Output is correct
6 Correct 279 ms 11140 KB Output is correct
7 Correct 224 ms 11084 KB Output is correct
8 Correct 255 ms 11008 KB Output is correct
9 Correct 207 ms 8796 KB Output is correct
10 Correct 233 ms 8956 KB Output is correct
11 Correct 259 ms 9132 KB Output is correct
12 Correct 257 ms 10408 KB Output is correct
13 Correct 233 ms 10700 KB Output is correct
14 Correct 300 ms 10984 KB Output is correct
15 Correct 256 ms 10912 KB Output is correct
16 Correct 228 ms 9532 KB Output is correct
17 Correct 211 ms 10404 KB Output is correct
18 Correct 184 ms 10700 KB Output is correct
19 Correct 177 ms 10568 KB Output is correct
20 Correct 142 ms 10632 KB Output is correct
21 Correct 274 ms 11412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 4588 KB Output is correct
2 Correct 18 ms 4736 KB Output is correct
3 Correct 165 ms 10312 KB Output is correct
4 Correct 258 ms 10432 KB Output is correct
5 Correct 223 ms 10544 KB Output is correct
6 Correct 231 ms 11032 KB Output is correct
7 Correct 160 ms 10320 KB Output is correct
8 Correct 177 ms 10404 KB Output is correct
9 Correct 171 ms 10600 KB Output is correct
10 Correct 217 ms 11028 KB Output is correct
11 Correct 258 ms 11012 KB Output is correct
12 Correct 218 ms 11120 KB Output is correct
13 Correct 269 ms 9056 KB Output is correct
14 Correct 245 ms 8912 KB Output is correct
15 Correct 193 ms 9060 KB Output is correct
16 Correct 234 ms 8988 KB Output is correct
17 Correct 211 ms 9196 KB Output is correct
18 Correct 238 ms 8968 KB Output is correct
19 Correct 216 ms 10344 KB Output is correct
20 Correct 229 ms 10664 KB Output is correct
21 Correct 218 ms 10952 KB Output is correct
22 Correct 235 ms 10956 KB Output is correct
23 Correct 251 ms 11016 KB Output is correct
24 Correct 208 ms 10860 KB Output is correct
25 Correct 214 ms 10920 KB Output is correct
26 Correct 208 ms 11032 KB Output is correct
27 Correct 160 ms 10616 KB Output is correct
28 Correct 147 ms 10632 KB Output is correct
29 Correct 172 ms 10688 KB Output is correct
30 Correct 151 ms 10576 KB Output is correct
31 Correct 152 ms 10584 KB Output is correct
32 Correct 182 ms 10452 KB Output is correct
33 Correct 181 ms 10828 KB Output is correct
34 Correct 173 ms 10584 KB Output is correct
35 Correct 168 ms 10704 KB Output is correct
36 Correct 204 ms 10468 KB Output is correct
37 Correct 163 ms 10760 KB Output is correct
38 Correct 216 ms 10588 KB Output is correct
39 Correct 236 ms 11444 KB Output is correct
40 Correct 204 ms 11448 KB Output is correct
41 Correct 249 ms 11460 KB Output is correct
42 Correct 212 ms 11420 KB Output is correct