답안 #224572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224572 2020-04-18T12:43:11 Z kshitij_sodani Pilot (NOI19_pilot) C++17
89 / 100
1000 ms 110968 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
llo par[1000001];
llo ss[1000001];
vector<llo> it[1000001];
vector<llo> tt[1000001];
llo find(llo no){

	if(par[no]==no){
		return no;
	}
	par[no]=find(par[no]);
	return par[no];
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n,q;
	cin>>n>>q;
	for(llo i=0;i<n;i++){
		par[i]=i;
		ss[i]=0;
	}
	
	llo aa;
	for(llo i=0;i<n;i++){
		cin>>aa;
		it[aa].pb(i);
	}
	llo ans2[q];
	
	for(llo i=0;i<q;i++){
		cin>>aa;
		tt[aa].pb(i);
	}


	llo ans=0;
	for(llo k=0;k<1000001;k++){

		for(llo j=0;j<it[k].size();j++){

			llo ind=it[k][j];
			ss[ind]=1;
			ans+=1;
			if(ind>0){
				if(ss[ind-1]>0){
					llo x=find(ind-1);
					
					ans+=(llo)ss[x];
					ss[x]+=ss[ind];
					par[ind]=x;
				}
				
			}
			if(ind<n-1){
				if(ss[ind+1]>0){
					llo y=find(ind);
					llo x=find(ind+1);
					if(ss[x]>ss[y]){
						ans+=(llo)(ss[x]*ss[y]);
						ss[x]+=ss[y];
						par[y]=x;
					}
					else{
					
						ans+=(llo)(ss[x]*ss[y]);
						ss[y]+=ss[x];
						par[x]=y;
					}

				}
			}
		}
		for(llo j=0;j<tt[k].size();j++){
			ans2[tt[k][j]]=ans;
		}
	}
	for(llo i=0;i<q;i++){
		cout<<ans2[i]<<endl;
	}




	return 0;
}

Compilation message

pilot.cpp: In function 'int main()':
pilot.cpp:48:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(llo j=0;j<it[k].size();j++){
               ~^~~~~~~~~~~~~
pilot.cpp:82:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(llo j=0;j<tt[k].size();j++){
               ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 47360 KB Output is correct
2 Correct 33 ms 47360 KB Output is correct
3 Correct 32 ms 47360 KB Output is correct
4 Correct 32 ms 47360 KB Output is correct
5 Correct 33 ms 47360 KB Output is correct
6 Correct 32 ms 47360 KB Output is correct
7 Correct 36 ms 47360 KB Output is correct
8 Correct 33 ms 47360 KB Output is correct
9 Correct 33 ms 47360 KB Output is correct
10 Correct 33 ms 47360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 47360 KB Output is correct
2 Correct 33 ms 47360 KB Output is correct
3 Correct 32 ms 47360 KB Output is correct
4 Correct 32 ms 47360 KB Output is correct
5 Correct 33 ms 47360 KB Output is correct
6 Correct 32 ms 47360 KB Output is correct
7 Correct 36 ms 47360 KB Output is correct
8 Correct 33 ms 47360 KB Output is correct
9 Correct 33 ms 47360 KB Output is correct
10 Correct 33 ms 47360 KB Output is correct
11 Correct 34 ms 47360 KB Output is correct
12 Correct 33 ms 47360 KB Output is correct
13 Correct 33 ms 47360 KB Output is correct
14 Correct 33 ms 47360 KB Output is correct
15 Correct 33 ms 47360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 47360 KB Output is correct
2 Correct 33 ms 47360 KB Output is correct
3 Correct 32 ms 47360 KB Output is correct
4 Correct 32 ms 47360 KB Output is correct
5 Correct 33 ms 47360 KB Output is correct
6 Correct 32 ms 47360 KB Output is correct
7 Correct 36 ms 47360 KB Output is correct
8 Correct 33 ms 47360 KB Output is correct
9 Correct 33 ms 47360 KB Output is correct
10 Correct 33 ms 47360 KB Output is correct
11 Correct 34 ms 47360 KB Output is correct
12 Correct 33 ms 47360 KB Output is correct
13 Correct 33 ms 47360 KB Output is correct
14 Correct 33 ms 47360 KB Output is correct
15 Correct 33 ms 47360 KB Output is correct
16 Correct 32 ms 47360 KB Output is correct
17 Correct 33 ms 47360 KB Output is correct
18 Correct 34 ms 47360 KB Output is correct
19 Correct 33 ms 47360 KB Output is correct
20 Correct 35 ms 47360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 47360 KB Output is correct
2 Correct 33 ms 47360 KB Output is correct
3 Correct 32 ms 47360 KB Output is correct
4 Correct 32 ms 47360 KB Output is correct
5 Correct 33 ms 47360 KB Output is correct
6 Correct 32 ms 47360 KB Output is correct
7 Correct 36 ms 47360 KB Output is correct
8 Correct 33 ms 47360 KB Output is correct
9 Correct 33 ms 47360 KB Output is correct
10 Correct 33 ms 47360 KB Output is correct
11 Correct 34 ms 47360 KB Output is correct
12 Correct 33 ms 47360 KB Output is correct
13 Correct 33 ms 47360 KB Output is correct
14 Correct 33 ms 47360 KB Output is correct
15 Correct 33 ms 47360 KB Output is correct
16 Correct 32 ms 47360 KB Output is correct
17 Correct 33 ms 47360 KB Output is correct
18 Correct 34 ms 47360 KB Output is correct
19 Correct 33 ms 47360 KB Output is correct
20 Correct 35 ms 47360 KB Output is correct
21 Correct 34 ms 47360 KB Output is correct
22 Correct 34 ms 47360 KB Output is correct
23 Correct 35 ms 47352 KB Output is correct
24 Correct 36 ms 47360 KB Output is correct
25 Correct 35 ms 47232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 50808 KB Output is correct
2 Correct 75 ms 51832 KB Output is correct
3 Correct 60 ms 50808 KB Output is correct
4 Correct 72 ms 51448 KB Output is correct
5 Correct 59 ms 50680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 265 ms 55972 KB Output is correct
2 Correct 275 ms 56056 KB Output is correct
3 Correct 263 ms 55932 KB Output is correct
4 Correct 279 ms 56184 KB Output is correct
5 Correct 266 ms 55952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 270 ms 56104 KB Output is correct
2 Correct 275 ms 56056 KB Output is correct
3 Correct 289 ms 56184 KB Output is correct
4 Correct 269 ms 56312 KB Output is correct
5 Correct 281 ms 56312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 47360 KB Output is correct
2 Correct 33 ms 47360 KB Output is correct
3 Correct 32 ms 47360 KB Output is correct
4 Correct 32 ms 47360 KB Output is correct
5 Correct 33 ms 47360 KB Output is correct
6 Correct 32 ms 47360 KB Output is correct
7 Correct 36 ms 47360 KB Output is correct
8 Correct 33 ms 47360 KB Output is correct
9 Correct 33 ms 47360 KB Output is correct
10 Correct 33 ms 47360 KB Output is correct
11 Correct 61 ms 50808 KB Output is correct
12 Correct 75 ms 51832 KB Output is correct
13 Correct 60 ms 50808 KB Output is correct
14 Correct 72 ms 51448 KB Output is correct
15 Correct 59 ms 50680 KB Output is correct
16 Correct 60 ms 50808 KB Output is correct
17 Correct 80 ms 51704 KB Output is correct
18 Correct 77 ms 51832 KB Output is correct
19 Correct 57 ms 50680 KB Output is correct
20 Correct 76 ms 51704 KB Output is correct
21 Correct 58 ms 50680 KB Output is correct
22 Correct 78 ms 51576 KB Output is correct
23 Correct 67 ms 50936 KB Output is correct
24 Correct 72 ms 51448 KB Output is correct
25 Correct 61 ms 50812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 47360 KB Output is correct
2 Correct 33 ms 47360 KB Output is correct
3 Correct 32 ms 47360 KB Output is correct
4 Correct 32 ms 47360 KB Output is correct
5 Correct 33 ms 47360 KB Output is correct
6 Correct 32 ms 47360 KB Output is correct
7 Correct 36 ms 47360 KB Output is correct
8 Correct 33 ms 47360 KB Output is correct
9 Correct 33 ms 47360 KB Output is correct
10 Correct 33 ms 47360 KB Output is correct
11 Correct 34 ms 47360 KB Output is correct
12 Correct 33 ms 47360 KB Output is correct
13 Correct 33 ms 47360 KB Output is correct
14 Correct 33 ms 47360 KB Output is correct
15 Correct 33 ms 47360 KB Output is correct
16 Correct 32 ms 47360 KB Output is correct
17 Correct 33 ms 47360 KB Output is correct
18 Correct 34 ms 47360 KB Output is correct
19 Correct 33 ms 47360 KB Output is correct
20 Correct 35 ms 47360 KB Output is correct
21 Correct 34 ms 47360 KB Output is correct
22 Correct 34 ms 47360 KB Output is correct
23 Correct 35 ms 47352 KB Output is correct
24 Correct 36 ms 47360 KB Output is correct
25 Correct 35 ms 47232 KB Output is correct
26 Correct 61 ms 50808 KB Output is correct
27 Correct 75 ms 51832 KB Output is correct
28 Correct 60 ms 50808 KB Output is correct
29 Correct 72 ms 51448 KB Output is correct
30 Correct 59 ms 50680 KB Output is correct
31 Correct 265 ms 55972 KB Output is correct
32 Correct 275 ms 56056 KB Output is correct
33 Correct 263 ms 55932 KB Output is correct
34 Correct 279 ms 56184 KB Output is correct
35 Correct 266 ms 55952 KB Output is correct
36 Correct 270 ms 56104 KB Output is correct
37 Correct 275 ms 56056 KB Output is correct
38 Correct 289 ms 56184 KB Output is correct
39 Correct 269 ms 56312 KB Output is correct
40 Correct 281 ms 56312 KB Output is correct
41 Correct 60 ms 50808 KB Output is correct
42 Correct 80 ms 51704 KB Output is correct
43 Correct 77 ms 51832 KB Output is correct
44 Correct 57 ms 50680 KB Output is correct
45 Correct 76 ms 51704 KB Output is correct
46 Correct 58 ms 50680 KB Output is correct
47 Correct 78 ms 51576 KB Output is correct
48 Correct 67 ms 50936 KB Output is correct
49 Correct 72 ms 51448 KB Output is correct
50 Correct 61 ms 50812 KB Output is correct
51 Correct 293 ms 55172 KB Output is correct
52 Correct 308 ms 55768 KB Output is correct
53 Correct 286 ms 55032 KB Output is correct
54 Correct 308 ms 55672 KB Output is correct
55 Correct 281 ms 54904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 47360 KB Output is correct
2 Correct 33 ms 47360 KB Output is correct
3 Correct 32 ms 47360 KB Output is correct
4 Correct 32 ms 47360 KB Output is correct
5 Correct 33 ms 47360 KB Output is correct
6 Correct 32 ms 47360 KB Output is correct
7 Correct 36 ms 47360 KB Output is correct
8 Correct 33 ms 47360 KB Output is correct
9 Correct 33 ms 47360 KB Output is correct
10 Correct 33 ms 47360 KB Output is correct
11 Correct 34 ms 47360 KB Output is correct
12 Correct 33 ms 47360 KB Output is correct
13 Correct 33 ms 47360 KB Output is correct
14 Correct 33 ms 47360 KB Output is correct
15 Correct 33 ms 47360 KB Output is correct
16 Correct 32 ms 47360 KB Output is correct
17 Correct 33 ms 47360 KB Output is correct
18 Correct 34 ms 47360 KB Output is correct
19 Correct 33 ms 47360 KB Output is correct
20 Correct 35 ms 47360 KB Output is correct
21 Correct 34 ms 47360 KB Output is correct
22 Correct 34 ms 47360 KB Output is correct
23 Correct 35 ms 47352 KB Output is correct
24 Correct 36 ms 47360 KB Output is correct
25 Correct 35 ms 47232 KB Output is correct
26 Correct 61 ms 50808 KB Output is correct
27 Correct 75 ms 51832 KB Output is correct
28 Correct 60 ms 50808 KB Output is correct
29 Correct 72 ms 51448 KB Output is correct
30 Correct 59 ms 50680 KB Output is correct
31 Correct 265 ms 55972 KB Output is correct
32 Correct 275 ms 56056 KB Output is correct
33 Correct 263 ms 55932 KB Output is correct
34 Correct 279 ms 56184 KB Output is correct
35 Correct 266 ms 55952 KB Output is correct
36 Correct 270 ms 56104 KB Output is correct
37 Correct 275 ms 56056 KB Output is correct
38 Correct 289 ms 56184 KB Output is correct
39 Correct 269 ms 56312 KB Output is correct
40 Correct 281 ms 56312 KB Output is correct
41 Correct 60 ms 50808 KB Output is correct
42 Correct 80 ms 51704 KB Output is correct
43 Correct 77 ms 51832 KB Output is correct
44 Correct 57 ms 50680 KB Output is correct
45 Correct 76 ms 51704 KB Output is correct
46 Correct 58 ms 50680 KB Output is correct
47 Correct 78 ms 51576 KB Output is correct
48 Correct 67 ms 50936 KB Output is correct
49 Correct 72 ms 51448 KB Output is correct
50 Correct 61 ms 50812 KB Output is correct
51 Correct 293 ms 55172 KB Output is correct
52 Correct 308 ms 55768 KB Output is correct
53 Correct 286 ms 55032 KB Output is correct
54 Correct 308 ms 55672 KB Output is correct
55 Correct 281 ms 54904 KB Output is correct
56 Execution timed out 1102 ms 110968 KB Time limit exceeded
57 Halted 0 ms 0 KB -