QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#594221#9313. Make Max02LjhWA 0ms9704kbC++142.6kb2024-09-27 20:25:402024-09-27 20:25:41

Judging History

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

  • [2024-09-27 20:25:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:9704kb
  • [2024-09-27 20:25:40]
  • 提交

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);//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;H;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);
    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,cnt)cerr<<a[i].vl<<" "; H;
		For(i,1,n) sz[i]=1,fa[i]=i;
		For(i,1,n) { 
			int at=a[i].id;
			if(at!=1&&qwq[at-1]<qwq[at]) { mer(at,at-1,1); }
			if(at!=1&&qwq[at-1]==qwq[at]) { mer(at,at-1,0); } 
			if(at!=n&&qwq[at+1]<qwq[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: 0
Wrong Answer
time: 0ms
memory: 9704kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1 2 


2 2 


1
1 2 


2 2 


0
1 2 3 4 5 6 7 


2 2 3 4 5 6 7 


3 3 3 4 5 6 7 


4 4 4 4 5 6 7 


5 5 5 5 5 6 7 


6 6 6 6 6 6 7 


7 7 7 7 7 7 7 


3
1 2 3 


2 2 3 


3 3 3 


3

result:

wrong answer 2nd numbers differ - expected: '0', found: '2'