Submission #997296

#TimeUsernameProblemLanguageResultExecution timeMemory
997296faqinyeagerStone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; using ll = long long; int n; vector<int> a; int G(const vector<int>& b, ll x){ int l = 0, r = b.size() - 1; while(r - l > 1){ int mid = (l + r) / 2; if(a[mid] >= x) r = mid; else l = mid; } return b[l]; } int main(){ cin >> n; a.resize(n); map<int, vector<int>> tmp; for(int i = 0; i < n; i++) cin >> a[i], tmp[a[i]].push_back(i); int id = 0, pr = 0; while(id < n){ int cur = a[id]; const vector<int>& positions = tmp[cur]; int start = G(positions, id), end = positions.back(); //cout << cur << ' ' << id << " ---> " << start << ' ' << end << '\n'; for(int i = start; i <= end; i++) cout << cur<< '\n'; id = end + 1; if(id > n) break; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:28:17: warning: unused variable 'pr' [-Wunused-variable]
   28 |     int id = 0, pr = 0;
      |                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...