QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#626398 | #5420. Inscryption | zhoudashuai | WA | 0ms | 3700kb | C++14 | 1.5kb | 2024-10-10 07:55:15 | 2024-10-10 07:55:15 |
Judging History
answer
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
#include<unordered_map>
#include<iomanip>
#include<cassert>
#define fi first
#define se second
#define endl '\n'
#define pb push_back
#define ep emplace_back
#define debug(x) cout<<x<<'\n'
#define RES cout<<res<<'\n'
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define me(a,x) memset(a,x,sizeof(a))
#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define r23 cout<<233<<endl;return;
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;
typedef unsigned long long ull;
const int N=1e5+5,P=131,mod=998244353;
int qmi(int a,int b){
int res=1;
while(b){
if(b&1)res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
int inv(int a,int b){
return qmi(a,b-2);
}
void solve(){
int n;cin>>n;
int sum=1,cnt=1,f=1;
L(i,1,n){
int x;cin>>x;
if(x==1){
sum++,cnt++;
}else if(x==-1){
if(cnt>1){
cnt--;
}else {
f=0;
}
}else{
if(cnt>1)cnt--;
else sum++,cnt++;
}
}
if(!f)cout<<-1<<endl;
else{
int t=__gcd(sum,cnt);
//cout<<t;
cout<<sum/t<<' '<<cnt/t<<endl;
}
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int T=1;
cin>>T;
while(T--){
solve();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3700kb
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 -1 -1 1 1 2 1 -1
result:
wrong answer 2nd lines differ - expected: '3 1', found: '-1'