QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#773542#9792. Ogre Sortucup-team3564#WA 2ms12160kbC++142.0kb2024-11-23 09:18:302024-11-23 09:18:32

Judging History

This is the latest submission verdict.

  • [2024-11-23 09:18:32]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 12160kb
  • [2024-11-23 09:18:30]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],v[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001],cnn,stt[1000001],an1;
char s[1000001];
struct p{long long q,w;}l[1000001],m[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
bool cmp(p qq,p ww){return qq.w>ww.w;}
int lowbit(int qq){return qq&(-qq);}
void change(int qq,int ww)
{
	for(int i=qq;i<=a;i+=lowbit(i)) u[i]+=ww;
}
long long query(long long qq)
{
	long long ann=0;
	for(int i=qq;i;i-=lowbit(i)) ann+=u[i];
	return ann;
}
long long get(long long qq)
{
	return qq+query(qq);
}
int main()
{
//	freopen("1.in","r",stdin);
	scanf("%lld",&a);
	for(int i=1;i<=a;i++)
	{
		scanf("%lld",&d[i]);
	}
	long long mxx=0;
	for(int i=1;i<=a;i++)
	{
		if(d[i]>mxx)
		{
			mxx=d[i];
			st[++cn]=i;
			v[i]=1;
		}
	}st[cn+1]=a+1;
	for(int i=cn;i>=1;i--)
	{
		for(int j=st[i]+1;j<=st[i+1]-1;j++)
		{
			l[++cnn]=p{j,d[j]};
		}
	}
	long long nww=cn;
	sort(l+1,l+cnn+1,cmp);
	for(int j=1;j<=cnn;j++)
	{
		while(nww>1&&l[j].w<d[st[nww-1]]) --nww;
		m[++an]=p{get(l[j].q),st[nww-1]+1};
		change(l[j].q,-1);
		change(st[nww-1]+1,1);
		an1+=st[nww-1]+1;
	}
	printf("%lld %lld\n",an1,an);
	for(int i=1;i<=an;i++) printf("%lld %lld\n",m[i].q,m[i].w);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 12112kb

input:

4
1 2 4 3

output:

3 1
4 3

result:

ok Participant's output is correct

Test #2:

score: 0
Accepted
time: 2ms
memory: 12068kb

input:

5
2 4 1 3 5

output:

3 2
4 2
4 1

result:

ok Participant's output is correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 10116kb

input:

3
1 2 3

output:

0 0

result:

ok Participant's output is correct

Test #4:

score: 0
Accepted
time: 2ms
memory: 12160kb

input:

4
1 2 4 3

output:

3 1
4 3

result:

ok Participant's output is correct

Test #5:

score: 0
Accepted
time: 1ms
memory: 12036kb

input:

5
2 4 1 3 5

output:

3 2
4 2
4 1

result:

ok Participant's output is correct

Test #6:

score: 0
Accepted
time: 1ms
memory: 10012kb

input:

3
1 2 3

output:

0 0

result:

ok Participant's output is correct

Test #7:

score: 0
Accepted
time: 1ms
memory: 9932kb

input:

1
1

output:

0 0

result:

ok Participant's output is correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 12128kb

input:

5
5 3 4 1 2

output:

4 4
3 1
3 1
5 1
5 1

result:

ok Participant's output is correct

Test #9:

score: 0
Accepted
time: 1ms
memory: 12128kb

input:

5
4 1 2 3 5

output:

3 3
4 1
4 1
4 1

result:

ok Participant's output is correct

Test #10:

score: 0
Accepted
time: 1ms
memory: 12048kb

input:

5
1 3 4 2 5

output:

2 1
4 2

result:

ok Participant's output is correct

Test #11:

score: -100
Wrong Answer
time: 1ms
memory: 12044kb

input:

5
1 4 5 2 3

output:

4 2
5 2
5 2

result:

wrong answer Integer parameter [name=participant answer] equals to 4, violates the range [0, 3]