QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#719975#9231. Random NumbersBreakPlus#WA 1ms5856kbC++141.3kb2024-11-07 10:06:512024-11-07 10:06:52

Judging History

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

  • [2024-11-07 10:06:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5856kb
  • [2024-11-07 10:06:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pr;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
// #define mid ((l+r)>>1)
#define popcnt __builtin_popcountll
const ll mod = 998244353;
inline ll read(){
	ll x=0, f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
	return x*f;
}
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline ll qpow(ll a,ll b){
	ll ans=1, base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod; b>>=1;
	}
	return ans;
}
void init(){ }
ll n,a[200005],sum[200005];

void procedure(){
	n=read();
	for(ll i=1;i<=n;i++) a[i]=read(),sum[i]=sum[i-1]+a[i];
	ll cnt=0;
	for(ll l=1;l<=n;l++){
		for(ll r=l;r<=min(n, l+500);r++){
			if((r-l+1)*(r-l+1) == sum[r]-sum[l-1]) cnt++;
		}

		ll pt=min(n,l+500)+1;

		ll mid = min(n, l+n/2);
		ll L = max(pt, mid-500), R = min(n, mid+500);

		for(ll r=L;r<=R;r++){
			if((r-l+1)*(r-l+1) == sum[r]-sum[l-1]) cnt++;
		}
	}
	printf("%lld\n", cnt);
}
int main(){
	#ifdef LOCAL
		assert(freopen("input.txt","r",stdin));
		assert(freopen("output.txt","w",stdout));
	#endif
	ll T=2;
	init();
	while(T--) procedure();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5856kb

input:

2
3
2 1 3
5
3 4 2 5 1

output:

0
0

result:

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