제출 #799065

#제출 시각아이디문제언어결과실행 시간메모리
799065acatmeowmeowStone Arranging 2 (JOI23_ho_t1)C++11
100 / 100
137 ms18336 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() && cnt[index] + 1 != cnt[index + 1]) { for (int i = cnt[index]; i <= cnt[index + 1]; i++) res[i] = arr[cnt[index]]; } else { res[cnt[index]] = arr[cnt[index]]; } index++; } for (int i = 1; i <= n; i++) cout << res[i] << '\n'; return 0; }

컴파일 시 표준 에러 (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:17: 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() && cnt[index] + 1 != cnt[index + 1]) {
      |       ~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...