제출 #1034597

#제출 시각아이디문제언어결과실행 시간메모리
1034597juicyStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
144 ms15336 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> A(N); map<int, int> cnt; vector<int> st; for (int i = 0; i < N; ++i) { cin >> A[i]; if (cnt[A[i]] > 0) { while (st.size() && A[st.back()] != A[i]) { --cnt[A[st.back()]]; st.pop_back(); } } ++cnt[A[i]]; st.push_back(i); } for (int i = 0; i < st.size(); ++i) { int l = st[i], r = i + 1 == st.size() ? N - 1 : st[i + 1] - 1; int cnt = r - l + 1; while (cnt--) { cout << A[l] << "\n"; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for (int i = 0; i < st.size(); ++i) {
      |                   ~~^~~~~~~~~~~
Main.cpp:30:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     int l = st[i], r = i + 1 == st.size() ? N - 1 : st[i + 1] - 1;
      |                        ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...