QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#509679#1968. Science FictionPetroTarnavskyi#Compile Error//C++201.3kb2024-08-08 17:13:502024-08-08 17:13:50

Judging History

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

  • [2024-08-08 17:13:50]
  • 评测
  • [2024-08-08 17:13:50]
  • 提交

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;

bool has_bit(int x, int bt)
{
	return (x >> bt) & 1;
}

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];
	
	VI srt = p;
	sort(ALL(srt));
	
	vector<PII> ans;
	
	FOR (en, 0, 1 << n)
	{
		int st = -1;
		FOR (pos, en, 1 << n)
		{
			if (srt[en] == p[pos])
			{
				st = pos;
				break;
			}
		}
		FOR (i, 0, n)
		{
			if (has_bit(en, i) && !has_bit(st, i))
			{
				ans.PB({st, st | (1 << i)});
				swap(p[st], p[st | (1 << i)]);
				st |= 1 << i;
			}
		}
		FOR (i, 0, n)
		{
			if (!has_bit(en, i) && has_bit(st, i))
			{
				ans.PB({st, st ^ (1 << i)});
				swap(p[st], p[st ^ (1 << i)]);
				st ^= 1 << i;
			}
		}
	}
	
	
	assert(is_sorted(ALL(p)));
	assert(SZ(ans) <= n * (1 << n));
	cout << SZ(ans) << '\n';
	for (auto [i, j] : ans)
		cout << i << ' ' << j << '\n';
	
	
	return 0;
}
123

詳細信息

answer.code:82:1: error: expected unqualified-id before numeric constant
   82 | 123
      | ^~~