제출 #941392

#제출 시각아이디문제언어결과실행 시간메모리
941392shoryu386Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
115 ms21120 KiB
#include <bits/stdc++.h> using namespace std; #define int long long main(){ int n; cin >> n; int arr[n]; for (int x = 0; x < n; x++) cin >> arr[x]; stack< tuple<int, int, int> > stk; unordered_multiset<int> valInStk; for (int x = 0; x < n; x++){ if (valInStk.find(arr[x]) != valInStk.end()){ int stopLoc = -1; while (!stk.empty()){ if ( get<2>(stk.top()) == arr[x]){ stopLoc = get<0>(stk.top()); valInStk.erase(valInStk.find(get<2>(stk.top()))); stk.pop(); break; } else{ valInStk.erase(valInStk.find(get<2>(stk.top()))); stk.pop(); } } assert(stopLoc != -1); stk.push({stopLoc, x, arr[x]}); valInStk.insert(arr[x]); } else{ stk.push({x, x, arr[x]}); valInStk.insert(arr[x]); } } int res[n]; memset(res, -1, sizeof(res)); while (!stk.empty()){ auto tup = stk.top(); for (int y = get<0>(tup); y <= get<1>(tup); y++){ res[y] = get<2>(tup); } stk.pop(); } for (int x = 0; x < n; x++) cout << res[x] << '\n'; }

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

Main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...