Submission #709066

#TimeUsernameProblemLanguageResultExecution timeMemory
709066mansurAbracadabra (CEOI22_abracadabra)C++17
10 / 100
252 ms524288 KiB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") #include<bits/stdc++.h> using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define sz(a) (int)a.size() #define pf push_front #define pb push_back #define vt vector #define s second #define f first #define nl '\n' using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); vt<pii> rid = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; vt<pii> dir = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; const int N = 5e5, mod = 1e9 + 7; const ll inf = 1e18; double eps = 1e-15; bool flg = 0; int p[N], n, q; void slv() { cin >> n >> q; for (int i = 1; i <= n; i++) cin >> p[i]; int ans[n + 1][n + 1]; for (int i = 1; i <= n; i++) ans[0][i] = p[i]; for (int t = 1; t <= n; t++) { vt<int> s, h; for (int i = 1; i <= n / 2; i++) s.pb(ans[t - 1][i]); for (int i = n / 2 + 1; i <= n; i++) h.pb(ans[t - 1][i]); vt<int> z; int i = 0, j = 0; while (i < sz(s) || j < sz(h)) { if (j == sz(h) || (i < sz(s) && s[i] < h[j])) z.pb(s[i++]); else z.pb(h[j++]); } for (i = 1; i <= n; i++) ans[t][i] = z[i - 1]; } while (q--) { int t, k; cin >> t >> k; t = min(t, n); cout << ans[t][k] << nl; } } main() { //freopen("shops.in", "r", stdin); //freopen("shops.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); int tp = 1; if (flg) cin >> tp; while (tp--) { slv(); } }

Compilation message (stderr)

Main.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...