Submission #971602

#TimeUsernameProblemLanguageResultExecution timeMemory
971602nguyentunglamAbracadabra (CEOI22_abracadabra)C++17
0 / 100
114 ms28048 KiB
#include<bits/stdc++.h> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int N = 1e5 + 10; int n, q; int a[N], b[N], c[N], ans[N]; vector<pair<int, int> > query[N]; int32_t main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } if (fopen(task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> q; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= q; i++) { int t, x; cin >> t >> x; query[min(n, t)].emplace_back(x, i); } // exit(0); b[n / 2 + 1] = c[n / 2 + 1] = 1e9; for(int turn = 0; turn <= n; turn++) { // for(int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl; for(auto &[x, i] : query[turn]) { if (x > n) return 0; ans[i] = a[x]; } // for(int i = 1; i <= n / 2; i++) b[i] = a[i]; // for(int i = n / 2 + 1; i <= n; i++) c[i - n / 2] = a[i]; // for(int i = 1, j = 1; i <= n / 2 || j <= n / 2; ) { // if (b[i] < c[j]) a[i + j - 1] = b[i], i++; // else a[i + j - 1] = c[j], j++; // } } for(int i = 1; i <= q; i++) cout << ans[i] << endl; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("task.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen("task.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:25:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen (task".inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:26:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen (task".out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...