QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578215 | #9313. Make Max | eastcloud# | WA | 296ms | 56036kb | C++20 | 1.5kb | 2024-09-20 17:26:33 | 2024-09-20 17:26:35 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pi pair<ll,ll>
#define vi vector<ll>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array
#define N 500005
using namespace std;
ll read(){
ll x=0,f=1;char ch=getchar();
while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
void write(ll x){
if(x<0)x=-x,putchar('-');
if(x/10)write(x/10);
putchar(x%10+'0');
}
ll sta[N],tp,a[N],b[N];
map<ll,vi > c;
ll f[N],siz[N],maxn[N];
ll res=0;
ll find(ll x){return (f[x]==x?x:f[x]=find(f[x]));}
void merge(ll x,ll y){
x=find(x);y=find(y);
if(x==y)return;
if(maxn[x]!=maxn[y])res+=siz[x];
siz[y]+=siz[x];f[x]=y;
}
void solve(){
ll n=read();c.clear();res=0;
for(ll i=1;i<=n;i++)a[i]=read(),f[i]=i,siz[i]=1,maxn[i]=a[i],c[a[i]].pb(i),b[i]=i;
sort(b+1,b+n+1);
for(ll i=1;i<=n;i++){
if(b[i]==b[i-1])continue;
ll col=b[i];
vi S=c[col];
for(auto v:S){
if(v!=1 && a[v-1]<=a[v])merge(v-1,v);
if(v!=n && a[v+1]<=a[v])merge(v+1,v);
}
}
write(res);putchar('\n');
}
int main(){
#ifdef EAST_CLOUD
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
ll T=read();while(T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11788kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 0 3 3
result:
ok 4 number(s): "1 0 3 3"
Test #2:
score: -100
Wrong Answer
time: 296ms
memory: 56036kb
input:
2 198018 875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...
output:
0 0
result:
wrong answer 1st numbers differ - expected: '4084978', found: '0'