Submission #971601

# Submission time Handle Problem Language Result Execution time Memory
971601 2024-04-29T04:22:17 Z nguyentunglam Abracadabra (CEOI22_abracadabra) C++17
0 / 100
112 ms 27984 KB
#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]) {
      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

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 time Memory Grader output
1 Runtime error 112 ms 27984 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 5980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 6288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 112 ms 27984 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -