Submission #895922

#TimeUsernameProblemLanguageResultExecution timeMemory
895922niterStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
140 ms16312 KiB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
using namespace std;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }

struct P{
    int st, ed, col;
};
ostream& operator<<(ostream& os, P A){ os << "\n[" << A.st << ", " << A.ed << "], color = " << A.col; }

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<P> v;
    map<int,int> pos;
    loop(i,0,n){
        int now; cin >> now;
        if(pos.count(now)){
            int ind = pos[now];
            while(v.size() > ind + 1){
                pos.erase(v.back().col);
                v.pop_back();
            }
            v.back().ed = i;
        }
        else{
            pos[now] = v.size();
            v.pb({i, i, now});
        }
//        STL(v)
    }
    for(auto &i:v){
        loop(j,0,i.ed - i.st + 1){
            cout << i.col << '\n';
        }
    }
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'std::ostream& operator<<(std::ostream&, std::pair<int, int>)':
Main.cpp:16:84: warning: no return statement in function returning non-void [-Wreturn-type]
   16 | ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }
      |                                                                                    ^
Main.cpp: In function 'std::ostream& operator<<(std::ostream&, P)':
Main.cpp:21:103: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | ostream& operator<<(ostream& os, P A){ os << "\n[" << A.st << ", " << A.ed << "], color = " << A.col; }
      |                                                                                                       ^
Main.cpp: In function 'int main()':
Main.cpp:32:28: warning: comparison of integer expressions of different signedness: 'std::vector<P>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |             while(v.size() > ind + 1){
      |                   ~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...