QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55754#1968. Science FictionAs3b_team_f_masr#WA 1ms3708kbC++1.7kb2022-10-15 00:09:572022-10-15 00:10:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-15 00:10:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2022-10-15 00:09:57]
  • 提交

answer

#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, -1, 0, 1, -1, 1};
int dj[] = {1, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 998244353;
const int N = 1105, M = 1e6 + 5;
const ld PI = acos(-1.0), EPS = 1e-9;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int n;
int a[N], vis[M];
pair<int, int> b[N];
vector<pair<int, int>> ans;


//#define endl '\n'
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("farm.in", "r", stdin);
    //memset(dp, -1, sizeof dp);
    cin >> n;
    srand(time(0));
    int m = 1 << n;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        b[i].first = a[i], b[i].second = i;
    }
    sort(b, b + m);
    for (int i = 0; i < m; i++) {
        int me = b[i].second;
        int to = i;
        while (me != i) {
            for (int j = 0; j < n; j++) {
                int num1 = min(1, me & (1 << j));
                int num2 = min(1, to & (1 << j));
                if (num1 ^ num2) {
                    swap(a[me], a[me ^ (1 << j)]);
                    me ^= (1 << j);
                    ans.push_back({me, me ^ (1 << j)});
                }
            }
        }
        for (int i = 0; i < m; i++) b[i].first = a[i], b[i].second = i;
        sort(b, b + m);
    }

    cout << ans.size() << '\n';
    for (auto x:ans) cout << x.first << " " << x.second << '\n';
    cout << is_sorted(a, a + m) << endl;
    return 0;
}

詳細信息

Test #1:

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

input:

2
3 2 10 4

output:

2
0 1
2 3
1

result:

wrong output format Extra information in the output file