QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55625#1968. Science FictionAs3b_team_f_masr#WA 2ms3688kbC++1.6kb2022-10-14 20:40:042022-10-14 20:40:07

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-14 20:40:07]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3688kb
  • [2022-10-14 20:40:04]
  • 提交

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 = 1005, M = 105;
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;
bool yes[N][N];
pair<int, int> a[N];
vector<pair<int, int>> ans;

bool cmp(pair<int, int> one, pair<int, int> two) {
    if (one.first < two.first && yes[one.second][two.second]) {
        ans.push_back({one.second, two.second});
        return 1;
    }
    return 0;
}

//#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;
    int m = 1 << n;
    for (int i = 0; i < m; i++) cin >> a[i].first, a[i].second = i;
    for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
            int num = 0;
            for (int k = 0; k < n; k++) {
                int num1 = min(1, a[i].first & (1 << k));
                int num2 = min(1, a[j].first & (1 << k));
                if (num1 ^ num2) num++;
            }
            if (num == 1) yes[i][j] = yes[j][i] = 1;
        }
    }
    sort(a, a + m, cmp);
    cout << ans.size() << endl;
    for (auto x:ans) cout << x.first << " " << x.second << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3572kb

input:

2
3 2 10 4

output:

2
1 0
3 2

result:

ok nice! 2 moves

Test #2:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

1
10 100

output:

0

result:

ok nice! 0 moves

Test #3:

score: 0
Accepted
time: 2ms
memory: 3688kb

input:

1
824838 992401

output:

0

result:

ok nice! 0 moves

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3544kb

input:

2
208395 17211 250690 874014

output:

0

result:

wrong answer array is not sorted