QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#313072#4831. Eager Sortingduongnc0000 1ms3692kbC++203.1kb2024-01-24 15:53:002024-01-24 15:53:01

Judging History

你现在查看的是最新测评结果

  • [2024-01-24 15:53:01]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3692kb
  • [2024-01-24 15:53:00]
  • 提交

answer

/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/

#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;

const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;

int inv[105], pos[105];

int query(int x, int y) {
    if (x == y) return 0;
    cout << x << " " << y << endl;
    int res; cin >> res;
    if (res == -1) exit(0);
    if (res == 1) {
        int ix = inv[x], iy = inv[y];
        pos[ix] = y, pos[iy] = x;
        inv[y] = ix, inv[x] = iy;
        // swap(pos[x], pos[y]);
    }
    return res; 
}

void merge(int l1, int r1, int l2, int r2) {
    assert(r1 + 1 == l2);
    // cout << "merge " << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
    iota(pos + l1, pos + r2 + 1, l1);
    iota(inv + l1, inv + r2 + 1, l1);

    int ptr = l1, len = (r1 - l1 + 1) + (r2 - l2 + 1);
    for (int i = 1; i < len; ++i) {
        // for (int i = 1; i <= 9; ++i) cout << pos[i] << " \n"[i == 9];
        // cout << i << " " << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
        if (l1 > r1) { query(ptr++, pos[l2++]); continue; }
        if (l2 > r2) { query(ptr++, pos[l1++]); continue; }

        int cpos = 0;
        if (ptr == pos[l1] or query(ptr, pos[l1])) cpos = l1;
        if (ptr == pos[l2] or query(ptr, pos[l2])) cpos = l2;

        ++ptr;
        if (cpos == l1) ++l1;
        else ++l2;
    }
}

int n;

void solve() {
    cin >> n;
    merge(1, 7, 8, 9);
    return;
    vector<pair<int, int>> v;
    int l = 1;
    for (int i = 1; i < n; ++i) {
        if (query(i, i + 1)) {
            if (i > 1) v.emplace_back(l, i - 1);
            l = i;
        }
    }
    v.emplace_back(l, n - 1);
    // for (auto [l, r] : v) cout << l << ", " << r << endl;
    while (isz(v) > 1) {
        vector<pair<int, int>> nv;
        for (int i = 0; i + 1 < isz(v); i += 2) {
            merge(v[i].ff, v[i].ss, v[i + 1].ff, v[i + 1].ss);
            nv.emplace_back(v[i].ff, v[i + 1].ss);
        }
        if (isz(v) & 1) nv.emplace_back(v.back());
        v.swap(nv);
    }
    cout << -1 << " " << -1 << endl;
}

signed main() {

#ifndef CDuongg
    if(fopen(taskname".inp", "r"))
        assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
    freopen("bai3.inp", "r", stdin);
    freopen("bai3.out", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; //cin >> t;
    while(t--) solve();

#ifdef CDuongg
   auto end = chrono::high_resolution_clock::now();
   cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
   cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
   cout << "Check array size pls sir" << endl;
#endif

}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3692kb

Interactor to First Run

5

First Run to Interactor

1 8

Interactor to Second Run


Second Run to Interactor


Manager to Checker

WA
Invalid Operation 1 8

result:

wrong answer WA