QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#509659#1968. Science FictionPetroTarnavskyi#WA 0ms3792kbC++20894b2024-08-08 16:59:042024-08-08 16:59:04

Judging History

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

  • [2024-08-08 16:59:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-08-08 16:59:04]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	VI p(1 << n);
	FOR (i, 0, SZ(p))
		cin >> p[i];
	
	vector<PII> ans;
	FOR (bt, 0, n)
	{
		FOR (mask, 0, 1 << n)
		{
			if ((mask & bt) & 1) continue;
			int i = mask;
			int j = mask | (1 << bt);
			if (p[i] > p[j])
			{
				swap(p[i], p[j]);
				ans.PB({i, j});
			} 
		}
	}
	cout << SZ(ans) << '\n';
	for (auto [i, j] : ans)
		cout << i << ' ' << j << '\n';
	
	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3792kb

input:

2
3 2 10 4

output:

2
0 1
2 3

result:

ok nice! 2 moves

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

1
10 100

output:

0

result:

ok nice! 0 moves

Test #3:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

1
824838 992401

output:

0

result:

ok nice! 0 moves

Test #4:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

2
208395 17211 250690 874014

output:

1
0 1

result:

ok nice! 1 moves

Test #5:

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

input:

8
991318 655714 983340 496226 752852 888298 572661 729100 426124 437775 8096 28612 303846 295897 970760 179029 702449 407420 945406 352294 960516 484993 724888 495235 156841 451864 95506 869159 61631 296168 279240 260130 901551 726353 298872 221580 982372 394731 720187 656498 595457 381795 759187 36...

output:

373
0 1
2 3
12 13
14 15
16 17
18 19
20 21
22 23
30 31
32 33
34 35
36 37
38 39
40 41
42 43
46 47
48 49
56 57
58 59
60 61
64 65
68 69
70 71
72 73
76 77
78 79
80 81
86 87
88 89
98 99
102 103
104 105
108 109
112 113
114 115
116 117
124 125
126 127
128 129
130 131
132 133
136 137
146 147
148 149
154 155
...

result:

wrong answer array is not sorted