답안 #931505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931505 2024-02-22T01:06:06 Z pcc Stone Arranging 2 (JOI23_ho_t1) C++14
100 / 100
235 ms 39416 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")

#define pii pair<int,int>
#define fs first
#define sc second


const int mxn = 2e5+10;
int arr[mxn];
int N;
map<int,vector<int>> mp;
vector<pair<pii,int>> vv;
set<int> st;
int ans[mxn];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N;
	for(int i = 1;i<=N;i++)cin>>arr[i];
	for(int i = 1;i<=N;i++){
		vector<int> &v = mp[arr[i]];
		st.insert(i);
		while(!v.empty()&&st.find(v.back()) == st.end())v.pop_back();
		if(!v.empty()){
			int l = v.back();
			while(!vv.empty()&&vv.back().fs.fs>=l)vv.pop_back();
			vv.push_back(make_pair(make_pair(l,i),arr[i]));
			vector<int> vvv;
			for(auto it = st.lower_bound(l);*it<i;it++){
				vvv.push_back(*it);
			}
			for(auto &j:vvv)st.erase(j);
		}
		else{
			vv.push_back(make_pair(make_pair(i,i),arr[i]));
		}
		mp[arr[i]].push_back(i);
	}
	for(auto &i:vv){
		for(int j = i.fs.fs;j<=i.fs.sc;j++)ans[j] = i.sc;
	}
	//for(auto &i:vv)cout<<i.fs.fs<<' '<<i.fs.sc<<':'<<i.sc<<endl;
	for(int i = 1;i<=N;i++){
		cout<<ans[i]<<'\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 33 ms 5596 KB Output is correct
18 Correct 34 ms 5672 KB Output is correct
19 Correct 36 ms 4064 KB Output is correct
20 Correct 35 ms 3816 KB Output is correct
21 Correct 35 ms 4128 KB Output is correct
22 Correct 36 ms 4156 KB Output is correct
23 Correct 38 ms 4064 KB Output is correct
24 Correct 36 ms 4324 KB Output is correct
25 Correct 35 ms 3968 KB Output is correct
26 Correct 36 ms 4064 KB Output is correct
27 Correct 36 ms 4160 KB Output is correct
28 Correct 36 ms 3900 KB Output is correct
29 Correct 34 ms 4064 KB Output is correct
30 Correct 37 ms 6708 KB Output is correct
31 Correct 33 ms 6112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 33 ms 5596 KB Output is correct
48 Correct 34 ms 5672 KB Output is correct
49 Correct 36 ms 4064 KB Output is correct
50 Correct 35 ms 3816 KB Output is correct
51 Correct 35 ms 4128 KB Output is correct
52 Correct 36 ms 4156 KB Output is correct
53 Correct 38 ms 4064 KB Output is correct
54 Correct 36 ms 4324 KB Output is correct
55 Correct 35 ms 3968 KB Output is correct
56 Correct 36 ms 4064 KB Output is correct
57 Correct 36 ms 4160 KB Output is correct
58 Correct 36 ms 3900 KB Output is correct
59 Correct 34 ms 4064 KB Output is correct
60 Correct 37 ms 6708 KB Output is correct
61 Correct 33 ms 6112 KB Output is correct
62 Correct 44 ms 7384 KB Output is correct
63 Correct 235 ms 28912 KB Output is correct
64 Correct 203 ms 29192 KB Output is correct
65 Correct 45 ms 5540 KB Output is correct
66 Correct 43 ms 5416 KB Output is correct
67 Correct 45 ms 5556 KB Output is correct
68 Correct 45 ms 5872 KB Output is correct
69 Correct 46 ms 5380 KB Output is correct
70 Correct 46 ms 4864 KB Output is correct
71 Correct 46 ms 5556 KB Output is correct
72 Correct 53 ms 4860 KB Output is correct
73 Correct 159 ms 21504 KB Output is correct
74 Correct 160 ms 20736 KB Output is correct
75 Correct 212 ms 37588 KB Output is correct
76 Correct 216 ms 39416 KB Output is correct
77 Correct 200 ms 37440 KB Output is correct
78 Correct 201 ms 38140 KB Output is correct