QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#188210 | #5741. Triterminant | 275307894a | WA | 2ms | 6524kb | C++14 | 1.3kb | 2023-09-25 16:46:16 | 2023-09-25 16:46:17 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=(1<<18)+5,M=N*20+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(263082);
int n,m,A[N],B[N],ans,w[N][2];
void Solve(int l,int r){
if(r-l+1==2) return;
if(r-l+1==4){
cerr<<w[l][0]<<' '<<w[l][1]<<'\n';
ans+=min(w[l][0],w[l][1])+min(w[l+2][0],w[l+2][1]);
return;
}
int m=l+r>>1;
for(int i=m+1;i<r-1;i+=2){
if(i==m/2*3-1) w[i-m][0]+=w[i][1],w[i-m][1]+=w[i][0];
else w[i-m][0]+=w[i][0],w[i-m][1]+=w[i][1];
}
Solve(l,m);
}
void Solve(){
int i,j;scanf("%d",&n);ans=0;
m=1<<__lg(n)+1;
for(i=1;i<=m;i++) Me(w[i],0);
for(i=1;i<=n;i++) scanf("%d",&A[i]);
A[n+1]=0;for(i=1;i<=n;i+=2){
if(A[i]==A[i+1]) ans++;
else w[i][A[i]==1]=1+(i!=n);
}
Solve(1,m);printf("%d\n",ans);
}
int main(){
int t=1;
scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 6084kb
input:
3 4 1 1 1 1 2 1 -1 5 -1 1 1 1 -1
output:
2 0 2
result:
ok 3 number(s): "2 0 2"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 6524kb
input:
3 27354 -1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 ...
output:
11963 24585 6264
result:
wrong answer 1st numbers differ - expected: '13567', found: '11963'