QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#594155 | #9313. Make Max | 02Ljh | WA | 65ms | 9924kb | C++14 | 2.5kb | 2024-09-27 19:46:08 | 2024-09-27 19:46:09 |
Judging History
answer
// 前を向け 終わらないさ
// 一生僕らは生きて征け
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ull unsigned long long
#define ll long long
#define WA cerr<<"meowww!\n";
#define eps 1e-5
#define none -1145141919
#define pii pair<int,int>
#define Y cout<<"Yes\n"
#define N cout<<"No\n"
#define H cout<<"\n";
#define WH cerr<<"\n";
#define fi first
#define se second
#define C continue;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define G(i,p) for(auto i:pq[p])
#define VG(i,p) for(int i=0;i<pq[p].size();i++)
#define pb push_back
#define pk pop_back
#define WR(x) cerr<<(x)<<"\n";
#define MAXN 200001
#define K cout<<" "
//#define int long long
//const int MOD=;
//void MD(int &x) { if(x<0) x+=MOD; if(x>=MOD) x-=MOD; return ; }
void Umn(int &x,int y) { if(x>y) x=y; return ; }
void Umx(int &x,int y) { if(x<y) x=y; return ; }
int rd() { int x; cin>>x; return x; }
void wr(int x) { cout<<x; return ; }
int n; int ans=0;
int sz[MAXN],fa[MAXN];
int fd(int x) { if(x==fa[x])return x;
int nx=fd(fa[x]);return fa[x]=nx; }
int qwq[MAXN]; int cnt=0;
struct meow{int vl,c,id,l,r;}a[MAXN];
bool cmp(meow x,meow y) { return x.vl<y.vl; }
void mer(int x,int y) { int nx=fd(y);//cerr<<"FK="<<x<<" "<<y<<"\n";
ans+=sz[nx];sz[nx]+=sz[x];fa[x]=nx; }
void add(int x,int y) { if(a[x].vl<a[y].vl&&fd(x)!=fd(y)) { mer(y,x); } }
//void pr(){For(i,1,cnt)cout<<fa[i]<<" ";H;For(i,1,cnt)cerr<<sz[i]<<" ";H;return ;}
int main()
{
//freopen("in2.txt","r",stdin);
//freopen("out.txt","w",stdout);
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int _; cin>>_;
for(int __=1;__<=_;__++)
{int tot=0,lst=0,fr=-1;cnt=0;
ans=0;
cin>>n; For(i,1,n) {int x;cin>>x; if(!lst){lst=x;tot=1,fr=1;C;}
if(lst!=x) {++cnt;a[cnt]={lst,tot,cnt,fr,i-1};lst=x,tot=0;fr=i;}++tot;}//1 2 3 1 3 2
++cnt;a[cnt]={lst,tot,cnt,fr,n};
sort(a+1,a+1+cnt,cmp);//For(i,1,cnt){pq[]}
//For(i,1,cnt)cerr<<a[i].vl<<" "; H;
For(i,1,cnt) sz[i]=a[i].c,fa[i]=i;
For(i,1,cnt) { if(i!=1)add(i-1,i);if(i!=cnt)add(i,i+1);;}
cout<<ans<<"\n";
}
return 0;
}
/*
Need check before submit
1.INF=1e9 check if the val>=1e9 and only 0x3f3f3f3f and 0 can be memset!!!
2.Don't using getchar() unless is NESSASARY!!!
3.Enough size for the array!!!
4.Notice double's precision
5.CHECK UR LL OR ULL!!!
6.READ THE PROBLEM AGAIN AND AGAIN!!!
7.Check if for() is over int
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5672kb
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: 65ms
memory: 9924kb
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:
-2085127904 1401448722
result:
wrong answer 1st numbers differ - expected: '4084978', found: '-2085127904'