QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#225648#7615. Sequence FoldingluanmengleiWA 31ms9416kbC++171.4kb2023-10-24 22:10:022023-10-24 22:10:02

Judging History

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

  • [2023-10-24 22:10:02]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:9416kb
  • [2023-10-24 22:10:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
bool stB;
namespace SOL {

void debug(const char *msg, ...) {
#ifdef CLESIP
    va_list arg;
    static char pbString[512];
    va_start(arg,msg);
    vsprintf(pbString,msg,arg);
    cerr << "[DEBUG] " << pbString << "\n";
    va_end(arg);
#endif    
}

#define PASSED cerr << "PASSED " << __FUNCTION__ << " #" << __LINE__ << "\n";

using i64 = long long;
using i128 = __int128_t;
template <typename T, typename L> void chkmax(T &x, L y) { if (x < y) x = y; }
template <typename T, typename L> void chkmin(T &x, L y) { if (y < x) x = y; }

i64 work(i64 len, vector<i64> seq) {
	if (len == 1) {
		return 0;
	}
	// debug("len: %lld", len);
	// for (auto x : seq)
	// 	debug("in seq %lld", x);
	set<i64> s;
	for (auto x : seq)
		s.insert(x);
	int extra = 0;
	for (auto x : seq) {
		if (s.find(len - x + 1) == s.end()) {
			++ extra;
		}
	}
	vector<i64> nxt;
	for (int x : seq) {
		if (x <= len / 2 && s.count(len - x + 1))
			nxt.push_back(x);
	}
	return extra + work(len / 2, nxt);
}

void solve() {
	i64 n; int m;
	cin >> n >> m;
	vector<i64> seq(m);
	for (int i = 0; i < m; i ++)
		cin >> seq[i];
	cout << work(n, seq);
}

}
bool edB;
signed main() {
	// cerr << "Memory: " << (&stB - &edB) / 1024.0 / 1024.0 << "MB\n";
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	SOL::solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3432kb

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 31ms
memory: 9416kb

input:

17179869184 100000
138476 774165 993977 1152277 1236393 1244970 1534017 1693701 1763926 1778781 1842066 1874644 1885666 2120429 2485344 2977941 3158255 3340476 3504862 4000117 4066652 4197639 4338723 4389163 4576965 4761601 5097091 5175412 5295902 5810551 5855982 6001770 6111262 6163309 6351547 6582...

output:

99998

result:

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