QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55185#4803. CandiesGZU_addd#WA 8ms5320kbC++1.9kb2022-10-12 17:25:532022-10-12 17:25:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-12 17:25:54]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:5320kb
  • [2022-10-12 17:25:53]
  • 提交

answer

#include<bits/stdc++.h>
#define ls u<<1
#define rs u<<1|1
#define fi first
#define se second
#define min amin
#define max amax
#define pb push_back
#define pq priority_queue
#define vt vector
#define lb(x) (x&-x)
#define sub(i,j) ((1LL*i-1LL*j)%k+k)%k
std::mt19937 rnd(233);
using namespace std;
using ll=long long;
using node=pair<int,int>;
using nnode=array<int,3>;
//inline int read(){
//	int x=0,f=1;
//	char c=getchar();
//	while(c<'0'||c>'9'){
//		if(c=='-') f=-1;
//		c=getchar();
//	}
//	while(c>='0'&&c<='9'){
//		x=x*10+(c^'0');
//		c=getchar();
//	}
//	return x*f;
//}
template<typename T=int>T read(){T x;cin>>x;return x;}
template<typename U,typename V>auto min(U x,V y){return x<y?x:y;}
template<typename U,typename V>auto max(U x,V y){return x>y?x:y;}
template<typename U,typename...V>auto min(U x,V...y){return min(x,min(y...));}
template<typename U,typename...V>auto max(U x,V...y){return max(x,max(y...));}
template<typename U,typename V>bool cmin(U &x,V y){return x>y?x=y,true:false;}
template<typename U,typename V>bool cmax(U &x,V y){return x<y?x=y,true:false;}
constexpr int mod=998244353;
ll qpow(int x,int n=mod-2){ll y=1;for(;n;n>>=1,x=1LL*x*x%mod)if(n&1)y=1LL*y*x%mod;return y;}
//inline ll qpow(ll a, ll n=mod-2) { ll ans = 1;    while (n) { if (n & 1) { ans *= a; }a *= a; n >>= 1; }return ans; }
constexpr int N=1e5+10,M=3e7+10;
constexpr int inf=1e6;
ll n,a[N],x,ans,pre[N];
bool v[N];
void solve(){
	cin>>n>>x;
	for(int i=1;i<=n;++i)cin>>a[i];
	pre[1]=1;
	for(int i=2;i<=n;++i){
		if(a[i]==a[pre[i-1]]||a[i]+a[pre[i-1]]==x){
			v[i]=1,v[pre[i-1]]=1;
			++ans;
			pre[i]=pre[pre[i-1]-1];
		}
		else pre[i]=i;
	}
	int l=1,r=n;
	while(v[l])++l;
	while(v[r])--r;
	if(l<r){
		while(l<r&&(a[l]==a[r]||a[l]+a[r]==x))++ans,++l,--r;
	}
	cout<<ans<<'\n';
}
int main(){
	cin.sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
//	for(int T=read();T--;solve());
	solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3668kb

input:

6 5
1 1 4 5 1 4

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

10 5
1 2 5 2 1 2 3 4 8 4

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

1 963837006
731841442

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

2 948507270
461613425 139535653

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 8ms
memory: 5216kb

input:

100000 253614967
278270961 980235896 498158919 928430171 216003120 852570559 948400591 239257297 897053668 294741177 38297442 382677591 406314558 609468974 854148233 314532768 738191552 158215003 5865826 920471827 380037059 356271729 749175328 28319050 208101106 953758996 896570759 521930645 2413736...

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: -100
Wrong Answer
time: 8ms
memory: 5320kb

input:

100000 2
1 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 1 2 1 1 1 2 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 1 1 2 1 1 2 2 2 2 1 2 2 2 1 1 2 1 2 1 2 2 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 2 2 1 1 2 1 1 2 2 2 2 2 2 2 1 2 1 1 2 2 1 1 2 1 1 1 1...

output:

50767

result:

wrong answer 1st numbers differ - expected: '49999', found: '50767'