QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710778#5420. InscryptioninoaderWA 94ms3616kbC++14858b2024-11-04 21:42:002024-11-04 21:42:01

Judging History

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

  • [2024-11-04 21:42:01]
  • 评测
  • 测评结果:WA
  • 用时:94ms
  • 内存:3616kb
  • [2024-11-04 21:42:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
inline int read(){
	int x=0,k=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')k=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*k;
}
struct node{
	int x,y;
};
bool cmp(node a,node b){
	return a.x*1.0/a.y>b.x*1.0/b.y;
}
void sol(){
	int n=read();
	int a=1,b=1,c=0;
	bool f=0;
	for(int i=1;i<=n;++i){
		int t=read();
		if(t==1)++a,++b;
		else if(t==-1)--b;
		else ++a,++b,++c;
		if(b<1)f=1;
	}
	if(f){
		puts("-1");
		return;
	}
	vector<node>v;
	do{
		v.push_back({a,b});
		a--;
		b-=2;
		c--;
	}while(b>0&&~c);
	sort(v.begin(),v.end(),cmp);
	int x=v.begin()->x,y=v.begin()->y;
	int g=__gcd(x,y);
	cout<<x/g<<' '<<y/g<<endl;
}
signed main(){
	int T=read();
	while(T--)sol();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3616kb

input:

6
7
1 1 1 -1 1 1 -1
4
1 0 -1 0
4
0 -1 -1 0
1
0
2
0 0
1
-1

output:

3 2
3 1
-1
1 1
2 1
-1

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 94ms
memory: 3608kb

input:

1000000
1
1
1
-1
1
1
1
1
1
1
1
1
1
-1
1
-1
1
0
1
0
1
1
1
0
1
-1
1
0
1
1
1
0
1
1
1
0
1
1
1
0
1
0
1
0
1
1
1
-1
1
1
1
1
1
-1
1
0
1
1
1
0
1
-1
1
0
1
-1
1
1
1
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2
4 3
2 1
-1
5 3
3 1
6 1
-1
2 1
2 1
-1
1 1
-1
3 1
-1
-1
4 1
1 1
2 1
5 2
-1
3 1
3 1...

result:

wrong answer 28th lines differ - expected: '5 4', found: '2 1'