Submission #799061

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7990612023-07-31 09:09:24acatmeowmeowStone Arranging 2 (JOI23_ho_t1)C++11
0 / 100
1 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5;
int n, arr[N + 5], res[N + 5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >>n;
for (int i = 1; i <= n; i++) cin >> arr[i];
multiset<int> st;
vector<int> cnt;
for (int i = 1; i <= n; i++) {
if (st.find(arr[i]) == st.end()) cnt.push_back(i);
else {
while (cnt.size() && arr[cnt.back()] != arr[i]) st.erase(st.find(arr[cnt.back()])), cnt.pop_back();
cnt.push_back(i);
}
st.insert(arr[i]);
}
int index = 0;
while (index < cnt.size()) {
if(index + 1 < cnt.size() && arr[cnt[index]] == arr[cnt[index + 1]]) {
for (int i = cnt[index]; i <= cnt[index + 1]; i++) res[i] = arr[cnt[index]];
index += 2;
} else {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:26:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  while (index < cnt.size()) {
      |         ~~~~~~^~~~~~~~~~~~
Main.cpp:27:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   if(index + 1 < cnt.size() && arr[cnt[index]] == arr[cnt[index + 1]]) {
      |      ~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...