QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#223110#7615. Sequence Foldingucup-team484#WA 0ms3636kbC++171003b2023-10-21 21:41:522023-10-21 21:41:52

Judging History

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

  • [2023-10-21 21:41:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2023-10-21 21:41:52]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n; int m; cin >> n >> m;
	vector<pair<ll, int>> a(m);
	for (int i = 0; i < m; i++)
		cin >> a[i].st, a[i].nd = 1;
	int ans = 0;
	auto reduce = [&]() {
		vector<pair<ll, int>> b, c;
		set<ll> s;
		for (auto [x, y]: a)
			s.insert(x);
		for (auto [x, y]: a) {
			b.push_back({min(x, n - x + 1), y});
			if (y == 1) {
				if (!s.count(n - x + 1))
					b.back().nd = 2, ans++;
			}
		}
		sort(all(b));
		for (auto [x, y]: b) {
			if (!c.empty() && c.back().st == x)
				c.back().nd = max(y, c.back().nd);
			if (c.empty() || c.back().st != x)
				c.push_back(make_pair(x, y));
		}
		swap(a, b);
		m = sz(a);
	};
	while (n > 1) {
		reduce();
		n /= 2;
	}
	cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3636kb

input:

8 3
1 5 8

output:

3

result:

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