QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#860500#9975. Hitoshizukuucup-team4717#WA 17ms13888kbC++172.0kb2025-01-18 13:43:402025-01-18 13:43:41

Judging History

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

  • [2025-01-18 13:43:41]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:13888kb
  • [2025-01-18 13:43:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace IO{
    const int BUF=1<<21;
    char buff[BUF],*p1=buff,*p2=buff;
    #define gc() (p1==p2&&(p2=((p1=buff)+fread(buff,1,BUF,stdin)),p1==p2)?EOF:*p1++)
    template<typename T>inline void read(T &x){
        char ch=gc();x=0;int f=1;
        while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
        while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=gc();
        x*=f;
    }
    char obuf[BUF],*p3=obuf;
    inline void pc(char ch){
        if(p3-obuf<BUF) *p3++=ch;
        else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
    }
    inline void put(const char *s){while(*s) pc(*s),++s;}
    char ch[32],ctop;
    template<typename T>inline void print(T x){
    	if(x<0) x=~x+1,pc('-');
        if(!x) return pc(48);
        while(x) ch[++ctop]=x%10^48,x/=10;
        while(ctop) pc(ch[ctop--]);
    }
    inline void flush(){fwrite(obuf,p3-obuf,1,stdout);p3=obuf;}
}
using namespace IO;
const int N=3e5+5;
int T,n,vis[N];
struct node{int a,b,i;}a[N],b[N]; 
bool cmp(node x,node y){return x.a==y.a?x.b>y.b:x.a<y.a;}
bool cmp1(node x,node y){return x.b>y.b;}
int ans[N][3],cnt;
int main(){
	read(T);
	while(T--){
		read(n);n*=3;cnt=0;
		for(int i=1;i<=n;++i) read(a[i].a),read(a[i].b),a[i].i=i,b[i]=a[i],vis[i]=0;
		sort(a+1,a+n+1,cmp);
		sort(b+1,b+n+1,cmp1);
		priority_queue<pair<int,int>> hp;
		bool flag=1;
		for(int i=n,j=1;i;--i)if(!vis[i]){
			while(j<=n&&b[j].b>=a[i].a) hp.push({b[j].a,b[j].i}),++j;
			vis[ans[++cnt][0]=a[i].i]=1;
			while(!hp.empty()&&vis[hp.top().second]) hp.pop();
			if(hp.empty()){flag=0;break;}
			vis[ans[cnt][1]=hp.top().second]=1;hp.pop();
			while(!hp.empty()&&vis[hp.top().second]) hp.pop();
			if(hp.empty()){flag=0;break;}
			vis[ans[cnt][2]=hp.top().second]=1;hp.pop();
		}
		if(flag){
			put("Yes\n");
			for(int i=1;i<=cnt;++i) print(ans[i][0]),pc(' '),print(ans[i][1]),pc(' '),print(ans[i][2]),pc('\n');
		}else put("No\n");
	}
	flush();
	return 0;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 11852kb

input:

2
2
1 2
2 2
2 3
3 5
4 4
4 5
1
1 1
1 1000000000
1000000000 1000000000

output:

Yes
5 6 4
2 3 1
No

result:

ok >_< (2 test cases)

Test #2:

score: 0
Accepted
time: 15ms
memory: 13104kb

input:

100000
1
164154503 167959139
178382610 336470888
12298535 642802746
1
165064830 773386884
353585658 396628655
792066242 971207868
1
1607946 2087506
21674839 46761498
9518201 16843338
1
262361007 691952768
190585553 787375312
637191526 693319712
1
41970708 45277106
197619816 762263554
308360206 40724...

output:

No
No
No
Yes
3 1 2
No
Yes
3 2 1
No
No
No
No
No
Yes
2 3 1
Yes
3 2 1
No
No
No
No
Yes
2 1 3
No
Yes
2 1 3
No
No
Yes
2 1 3
No
No
Yes
2 3 1
No
No
No
No
No
No
No
Yes
3 1 2
No
No
Yes
3 2 1
No
No
No
No
No
No
No
No
No
No
No
No
Yes
3 1 2
No
No
Yes
3 1 2
Yes
1 2 3
No
No
Yes
3 1 2
No
No
No
Yes
2 3 1
Yes
3 1 2
No...

result:

ok >_< (100000 test cases)

Test #3:

score: -100
Wrong Answer
time: 17ms
memory: 13888kb

input:

50000
2
36364670 641009859
15071436 75475634
20446080 476927808
357784519 503158867
206641725 322595515
268011721 645468307
2
247717926 939887597
808609669 973764525
496738491 710156469
463547010 860350786
757388873 784695957
29903136 208427221
2
26681139 67590963
458238185 475357775
80127817 135993...

output:

No
No
No
No
No
No
No
Yes
5 1 4
4 6 2
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
5 4 3
1 2 6
No
No
No
Yes
4 5 3
1 6 2
No
No
No
No
No
No
No
Yes
1 4 2
3 6 5
No
No
No
No
No
No
Yes
5 4 1
2 3 6
No
No
Yes
5 3 1
3 6 2
No
No
No
Yes
2 1 4
1 5 3
No
No
No
Yes
2 5 1
1 3 6
No
No
Yes
6 3 2
3 4 1
No
No
...

result:

wrong answer There is no valid answer, but participant found one. (test case 8)