Submission #769058

#TimeUsernameProblemLanguageResultExecution timeMemory
769058danikoynovStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
221 ms19144 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 2e5 + 10; int n, a[maxn], b[maxn]; map < int, pair < int, int > > mp; void solve() { cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; stack < int > st; for (int i = 1; i <= n; i ++) { if (mp[a[i]].first == 0) { mp[a[i]] = {i, i}; st.push(a[i]); continue; } while(st.top() != a[i]) { mp[st.top()] = {0, 0}; st.pop(); } mp[a[i]].second = i; } for (pair < int, pair < int, int > > cur : mp) { for (int i = cur.second.first; i <= cur.second.second; i ++) b[i] = cur.first; } for (int i = 1; i <= n; i ++) cout << b[i] << endl; } int main() { solve(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:21:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   21 |     for (int i = 1; i <= n; i ++)
      |     ^~~
Main.cpp:24:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |         stack < int > st;
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...