Submission #1157938

#TimeUsernameProblemLanguageResultExecution timeMemory
1157938SmuggingSpunStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
216 ms13388 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n; cin >> n; vector<pair<int, int>>ans; map<int, bool>cnt; for(int _ = 0; _ < n; _++){ int x; cin >> x; if(cnt[x]){ int sum = 1; while(ans.back().first != x){ cnt[ans.back().first] = false; sum += ans.back().second; ans.pop_back(); } ans.back().second += sum; } else{ ans.emplace_back(x, 1); cnt[x] = true; } } for(auto& [u, v] : ans){ for(int i = 0; i < v; i++){ cout << u << "\n"; } } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:7:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...