Submission #924131

#TimeUsernameProblemLanguageResultExecution timeMemory
924131ErJStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
579 ms47096 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<ll> #define vvi vector<vector<ll>> #define vs vector<string> #define vc vector<char> #define vb vector<bool> #define vp vector<pair<ll, ll>> #define pp pair<ll, ll> #define qi queue<ll> #define qp queue<pp> #define pqi priority_queue<ll> #define pqp priority_queue<pp> #define mi map<ll, ll> #define mpi map<pp, ll> #define mip map<ll, pp> #define mpp map<pp, pp> #define mb map<ll, bool> #define si set<ll> #define sp set<pp> #define mod 1000000007 #define rep(a, b) for(int a = 0; a < (b); a++) #define inf 100000000111111111 int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vi A(n), input(n); mi color, decolor; int akt = 0; rep(i, n) { cin >> A[i]; if (!color.count(A[i])) { color[A[i]] = akt; decolor[akt] = A[i]; akt++; } input[i] = A[i]; } vector<vp> B(akt); vector<pair<pp, int>> ted; rep(i, n) { int x = color[A[i]]; if (B[x].empty()) { B[x].push_back({ i, i }); ted.push_back({ {i, i}, x }); } else { while (ted.back().second != x) { int y = ted.back().second; B[y].pop_back(); ted.pop_back(); } pair<pp, int> k = ted.back(); ted.pop_back(); B[k.second].pop_back(); pair<pair<int, int>, int> k2 = { {k.first.first, i}, k.second}; B[k.second].push_back(k2.first); ted.push_back(k2); } } rep(i, ted.size()) { pair<pp, int> ans = ted[i]; for (int j = ans.first.first; j <= ans.first.second; j++) { cout << decolor[ans.second] << endl; } } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:24:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, long long int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 | #define rep(a, b) for(int a = 0; a < (b); a++)
      |                                    ^
Main.cpp:68:5: note: in expansion of macro 'rep'
   68 |     rep(i, ted.size()) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...