Submission #315264

# Submission time Handle Problem Language Result Execution time Memory
315264 2020-10-22T07:36:34 Z mosiashvililuka City (JOI17_city) C++14
22 / 100
637 ms 78320 KB
#include<bits/stdc++.h>
#include "Encoder.h"
using namespace std;
const long long N=250009;
long long a,b,c,d,e,i,j,lf[250009],rg[250009],f[250009],tim;
vector <long long> v[250009];
void dfs(long long q, long long w){
	tim++;
	lf[q]=rg[q]=tim;
	for(vector <long long>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if((*it)==w) continue;
		dfs((*it),q);
		if(rg[q]<rg[(*it)]) rg[q]=rg[(*it)];
	}
}
void Encode(int n, int A[], int B[]){
	a=n;
	for(i=0; i<a-1; i++){
		v[A[i]+1].push_back(B[i]+1);
		v[B[i]+1].push_back(A[i]+1);
	}
	dfs(1,0);
	for(i=1; i<=a; i++) Code(i-1,lf[i]*N+rg[i]);
}
#include<bits/stdc++.h>
#include "Device.h"
using namespace std;
const long long n=250009;
long long l[4],r[4];
void InitDevice() {
    
}
bool anc(long long q, long long w){
	if(l[q]<=l[w]&&r[q]>=r[w]) return 1; else return 0;
}
int Answer(long long S, long long T) {
	swap(S,T);
    l[1]=S/n;r[1]=S%n;
    l[2]=T/n;r[2]=T%n;
    if(anc(1,2)) return 0;
    if(anc(2,1)) return 1;
    return 2;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 12544 KB Output is correct
2 Correct 4 ms 12544 KB Output is correct
3 Correct 4 ms 12544 KB Output is correct
4 Correct 6 ms 12544 KB Output is correct
5 Correct 6 ms 12544 KB Output is correct
6 Correct 5 ms 12544 KB Output is correct
7 Correct 42 ms 12544 KB Output is correct
8 Correct 41 ms 12544 KB Output is correct
9 Correct 5 ms 12544 KB Output is correct
10 Correct 5 ms 12352 KB Output is correct
11 Correct 4 ms 12544 KB Output is correct
12 Correct 5 ms 12544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 218 ms 20720 KB Output is correct - L = 175007000
2 Correct 216 ms 25440 KB Output is correct - L = 174756990
3 Correct 210 ms 25080 KB Output is correct - L = 175007000
4 Correct 285 ms 25328 KB Output is correct - L = 175007000
5 Partially correct 547 ms 75504 KB Output is partially correct - L = 62502500000
6 Partially correct 554 ms 75760 KB Output is partially correct - L = 62502500000
7 Partially correct 554 ms 75504 KB Output is partially correct - L = 62502500000
8 Partially correct 591 ms 78320 KB Output is partially correct - L = 62502500000
9 Partially correct 518 ms 76488 KB Output is partially correct - L = 62502500000
10 Partially correct 615 ms 76712 KB Output is partially correct - L = 62502500000
11 Partially correct 469 ms 76488 KB Output is partially correct - L = 62502500000
12 Partially correct 545 ms 76488 KB Output is partially correct - L = 62502500000
13 Partially correct 505 ms 76064 KB Output is partially correct - L = 62502500000
14 Partially correct 572 ms 76008 KB Output is partially correct - L = 62502500000
15 Correct 213 ms 26608 KB Output is correct - L = 175007000
16 Correct 214 ms 26672 KB Output is correct - L = 175007000
17 Correct 251 ms 26608 KB Output is correct - L = 175007000
18 Partially correct 521 ms 74536 KB Output is partially correct - L = 62502500000
19 Partially correct 517 ms 74288 KB Output is partially correct - L = 62502500000
20 Partially correct 550 ms 74712 KB Output is partially correct - L = 62502500000
21 Partially correct 518 ms 76016 KB Output is partially correct - L = 62502500000
22 Partially correct 524 ms 74192 KB Output is partially correct - L = 62502500000
23 Partially correct 637 ms 74192 KB Output is partially correct - L = 62502500000
24 Partially correct 545 ms 73944 KB Output is partially correct - L = 62502500000
25 Partially correct 541 ms 73616 KB Output is partially correct - L = 62502500000
26 Partially correct 569 ms 73712 KB Output is partially correct - L = 62502500000
27 Partially correct 571 ms 73368 KB Output is partially correct - L = 62502500000