QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227295#7615. Sequence FoldingGiga_Cronos#WA 0ms3612kbC++231.5kb2023-10-27 10:57:062023-10-27 10:57:06

Judging History

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

  • [2023-10-27 10:57:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2023-10-27 10:57:06]
  • 提交

answer

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> pip;
#define MAXN (ll)(1e6 + 5)

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll n, m;
	cin >> n >> m;
	map<ll, pii> dp;
	vector<ll> pos;
	set<ll> pxx;
	for (int i = 0; i < m; i++) {
		ll x;
		cin >> x;
		x--;
		pos.push_back(x);
		pxx.insert(x);
	}
	ll p = 0;
	while ((1ll << p) != n)
		p++;
	for (auto x : pos) {
		dp[x] = pii(1, 0);
	}
	for (auto x : pos)
		if (!pxx.count(n - x - 1))
			dp[n - x - 1] = pii(0, 1);
	// for (auto x : dp) {
	// 	cout << x.first << ' ' << x.second.first << ' ' << x.second.second
	// 	     << "\n";
	// }

	for (int i = 0; i < p; i++) {
		vector<pip> tp;
		for (auto p : dp) {
			if (p.first < n / 2) {
				ll v0 = dp[p.first].first + dp[n - p.first - 1].first;
				ll v1 = dp[p.first].second + dp[n - p.first - 1].second;
				v0 = min(v0, v1 + 1);
				v1 = min(v1, v0 + 1);
				tp.push_back(pip(p.first, pii(v0, v1)));
			}
		}
		n /= 2;
		set<int> pxx;
		for (auto x : tp)
			pxx.insert(x.first);
		for (auto x : pxx)
			if (!pxx.count(n - x - 1))
				tp.push_back(pip(n - x - 1, pii(0, 1)));
		// cout << i << "\n";
		// sort(all(tp));
		// for (auto x : tp) {
		// 	cout << x.first << ' ' << x.second.first << ' ' << x.second.second
		// 	     << "\n";
		// }
		dp.clear();
		for (auto x : tp)
			dp[x.first] = x.second;
	}

	cout << dp[0].first << "\n";

	return 0;
}

詳細信息

Test #1:

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

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

1

result:

wrong answer 1st lines differ - expected: '0', found: '1'