QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#594259#9313. Make Max02LjhWA 200ms11636kbC++142.6kb2024-09-27 20:40:392024-09-27 20:40:39

Judging History

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

  • [2024-09-27 20:40:39]
  • 评测
  • 测评结果:WA
  • 用时:200ms
  • 内存:11636kb
  • [2024-09-27 20:40:39]
  • 提交

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,id;}a[MAXN];
bool cmp(meow x,meow y) { return (x.vl==y.vl)?(x.id<y.id):(x.vl<y.vl); }
void mer(int x,int y,bool t) { int nx=fd(x),ny=fd(y);if(nx==ny)return;//cerr<<"FK="<<x<<" "<<y<<"\n"; 
	if(t){ans+=sz[ny];}sz[nx]+=sz[ny];fa[ny]=nx; }
void pr(){For(i,1,n)fa[i]=fd(fa[i]);For(i,1,n)cout<<fa[i]<<" ";H;For(i,1,n)cerr<<sz[i]<<" ";H;WR(ans);return ;}
bool v[MAXN];
 main() 
{
    //freopen("in2.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//1 2 3 1 3 2
    int _; cin>>_;
	for(int __=1;__<=_;__++)
	{int tot=0,lst=0,fr=-1;cnt=0; 
		ans=0; For(i,1,n) v[i]=0;
		cin>>n; For(i,1,n) {cin>>qwq[i];a[i]={qwq[i],i};}//1 2 3 1 3 2
		sort(a+1,a+1+n,cmp);//For(i,1,cnt){pq[]}
		For(i,1,n)cerr<<a[i].id<<" "; H;
		For(i,1,n) sz[i]=1,fa[i]=i;
		For(i,1,n) { 
			int at=a[i].id;
			if(at!=1&&qwq[fa[at-1]]<qwq[fa[at]]) { mer(at,at-1,1); }
			if(at!=1&&qwq[fa[at-1]]==qwq[fa[at]]) { mer(at,at-1,0); } 
			if(at!=n&&qwq[fa[at+1]]<qwq[fa[at]]) { mer(at,at+1,1); } 
			//pr();
		}
		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: 0ms
memory: 7668kb

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: 0
Accepted
time: 180ms
memory: 11636kb

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:


4084978

4130372

result:

ok 2 number(s): "4084978 4130372"

Test #3:

score: -100
Wrong Answer
time: 200ms
memory: 11552kb

input:

2
195768
3086 1582 7854 5577 5243 2734 8054 4805 5686 7065 5555 2410 6240 7589 2889 3745 8094 9147 9438 1252 5497 5786 6655 4437 3933 2579 5722 9512 3117 1742 5362 2068 1853 4069 9231 1126 3991 420 2571 5517 3063 7279 8085 6111 5503 5980 50 6003 244 9684 6343 6517 1598 5223 5520 982 3932 1093 1149 7...

output:


5569478

5456181

result:

wrong answer 1st numbers differ - expected: '3061429', found: '5569478'