Submission #866609

#TimeUsernameProblemLanguageResultExecution timeMemory
866609yeediotStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
181 ms20660 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define F first #define S second #define all(x) x.begin(),x.end() #define pii pair<int,int> #define pb push_back #define sz(x) (int)(x.size()) #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) #define vi vector<int> #define vp vector<pii> #define vvi vector<vi> //Don't open the standings during contests. void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } map<int,int>mp; signed main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n; cin>>n; vector<pii>num; for(int i=0;i<n;i++){ int x; cin>>x; if(mp[x]){ int sum=0; while(num.back().F!=x){ sum+=num.back().S; mp[num.back().F]--; num.pop_back(); } num.back().S+=sum+1; } else{ num.pb({x,1}); mp[x]=1; } } for(auto j:num){ for(int i=0;i<j.S;i++){ cout<<j.F<<'\n'; } } } /* input: */

Compilation message (stderr)

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...