Submission #847524

#TimeUsernameProblemLanguageResultExecution timeMemory
847524SUNWOOOOOOOOAbracadabra (CEOI22_abracadabra)C++17
10 / 100
768 ms524288 KiB
#include <bits/stdc++.h> using namespace std; vector <vector <int>> deck; int n, q; vector <int> next_deck(vector <int> cur) { int i = 0, j = 0; vector <int> A; while (i < n / 2 || j < n / 2){ if (i != n / 2 && (j == n / 2 || cur[i] < cur[j + n / 2])) {A.push_back(cur[i]); i++;} else {A.push_back(cur[j + n / 2]); j++;} } return A; } int main() { vector <int> v; scanf("%d %d", &n, &q); for (int i = 0, a; i < n; i++) { scanf("%d", &a); v.push_back(a); } deck.push_back(v); for (int i = 0; i < n; i++){ vector <int> v = next_deck(deck.back()); if (v == deck.back()) break; deck.push_back(v); } vector <int> ans; while (q--){ int t, i; scanf("%d %d", &t, &i); t = min(t, (int) deck.size() - 1); ans.push_back(deck[t][i - 1]); } for (int elm : ans) printf("%d\n", elm); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
Main.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d %d", &t, &i);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...