Submission #708637

#TimeUsernameProblemLanguageResultExecution timeMemory
708637becaidoAbracadabra (CEOI22_abracadabra)C++17
10 / 100
3041 ms30620 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout (T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second const int SIZE = 2e5 + 5; const int QSIZ = 1e6 + 5; int n, q; int ans[QSIZ]; vector<int> a; tuple<int, int, int> ask[QSIZ]; vector<int> deal(vector<int> a) { vector<int> re; for (int i1 = 0, i2 = a.size() / 2; i1 < a.size() / 2 || i2 < a.size();) { if (i1 == a.size() / 2) re.pb(a[i2++]); else if (i2 == a.size()) re.pb(a[i1++]); else if (a[i1] < a[i2]) re.pb(a[i1++]); else re.pb(a[i2++]); } return re; } void solve() { cin >> n >> q; a.resize(n); for (int &x : a) cin >> x; FOR (i, 1, q) { auto &[t, p, id] = ask[i]; cin >> t >> p; id = i; } sort(ask + 1, ask + q + 1); auto last = a; int cur = 0; bool f = 1; FOR (i, 1, q) { auto [t, p, id] = ask[i]; while (f && cur < t) { cur++; a = deal(a); if (a == last) f = 0; last = a; } ans[id] = a[p - 1]; } FOR (i, 1, q) cout << ans[i] << '\n'; } int main() { Waimai; solve(); }

Compilation message (stderr)

Main.cpp: In function 'std::vector<int> deal(std::vector<int>)':
Main.cpp:32:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i1 = 0, i2 = a.size() / 2; i1 < a.size() / 2 || i2 < a.size();) {
      |                                         ~~~^~~~~~~~~~~~~~
Main.cpp:32:65: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i1 = 0, i2 = a.size() / 2; i1 < a.size() / 2 || i2 < a.size();) {
      |                                                              ~~~^~~~~~~~~~
Main.cpp:33:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (i1 == a.size() / 2) re.pb(a[i2++]);
      |             ~~~^~~~~~~~~~~~~~~
Main.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         else if (i2 == a.size()) re.pb(a[i1++]);
      |                  ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...