QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#589896#9231. Random Numbersucup-team2526Compile Error//C++201.3kb2024-09-25 20:32:232024-09-25 20:32:23

Judging History

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

  • [2024-09-25 20:32:23]
  • 评测
  • [2024-09-25 20:32:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)

void err() {
	std::cout << std::endl;
}

template<class T, class... Ts>
void err(T arg, Ts &... args) {
	std::cout << fixed << setprecision(10) << arg << ' ';
	err(args...);
}

const int maxn = 2e5 + 5;

void GENSHEN_START() {
	int n;cin >> n;
	vector<int> a(n + 5);
	vector<int> sum(n + 5);
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
	}
	for (int i = 1;i <= n;i++) {
		sum[i] = sum[i - 1] + a[i];
	}
	int d = (1 + n) / 2;
	map<pair<int,int>,int>mp;
	int ans = 0;
	for (int i = 1;i <= n;i++) {
		for (int j = max((int)i,i + d - (int)1000);j <= min(n,i + d + (int)1000);j++) {
			int val = sum[j] - sum[i - 1];
			if (val == (j - i + 1) * (j - i + 1)) {
				if (!mp[{i,j}]) ans++;
				mp[{i,j}]++;;
			}
		}
		for (int j = i;j <= min(n,i + (int)1000);j++) {
			int val = sum[j] - sum[i - 1];
			if (val == (j - i + 1) * (j - i + 1)) {
				if (!mp[{i,j}]) ans++;
				mp[{i,j}]++;
			}
		}
	}
	cout << ans << '\n';
	return ;
}

signed main()
{
	ios::sync_with_stdio(false);cin.tie(nullptr);
	for (int i = 1;i <= 2e5;i++) p2[i] = i * i;
	int T = 1;
	cin >> T;
	while (T--) GENSHEN_START();
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:59:38: error: ‘p2’ was not declared in this scope
   59 |         for (int i = 1;i <= 2e5;i++) p2[i] = i * i;
      |                                      ^~