QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55640 | #1968. Science Fiction | As3b_team_f_masr# | WA | 0ms | 3668kb | C++ | 1.6kb | 2022-10-14 21:26:16 | 2022-10-14 21:26:19 |
Judging History
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;
//#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, i & (1 << k));
int num2 = min(1, j & (1 << k));
if (num1 ^ num2) num++;
}
if (num == 1) yes[i][j] = yes[j][i] = 1;
}
}
for (int i = 0; i < m; i++) {
for (int j = i + 1; j < m; j++) {
if (a[i].first > a[i].second && yes[a[i].second][a[j].second] == 1) {
swap(a[i], a[j]);
ans.push_back({a[i].second, a[j].second});
}
}
}
cout << ans.size() << '\n';
for (auto x:ans) cout << x.first << " " << x.second << '\n';
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3668kb
input:
2 3 2 10 4
output:
4 1 0 3 1 2 0 1 0
result:
wrong answer array is not sorted