QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227298#7615. Sequence FoldingGiga_Cronos#WA 0ms3624kbC++231.3kb2023-10-27 10:59:362023-10-27 10:59:36

Judging History

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

  • [2023-10-27 10:59:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2023-10-27 10:59:36]
  • 提交

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<ll> 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)));
		dp.clear();
		for (auto x : tp)
			dp[x.first] = x.second;
	}

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

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

1

result:

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