QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637815#5420. InscryptionnnkWA 0ms3632kbC++201.5kb2024-10-13 14:10:162024-10-13 14:10:17

Judging History

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

  • [2024-10-13 14:10:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-10-13 14:10:16]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<math.h>
#include<map>
#include<bitset>
#include<numeric>
#include <cstring>
#include<array>
#include <string>  
#include<unordered_set>
using namespace std;
#define int long long
#define endl "\n"
#define mod 1000000007ll
#define IOS  ios::sync_with_stdio(false),cin.tie(nullptr)
#define syy return
const double pi = acos(-1.0);
using ll = long long;
using pii = pair<int, int>;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vint>;
using vpo = vector<pii>;
using tup = tuple<int, int, int>;
using vbl = vector<bool>;
constexpr int N = 500005, M = 2000006;//开足够的空间 注意无向图的双向边边数*2
constexpr ll inf = 3e18+5000;

void slove() {
	int n; cin >> n;
	vint a(n);
	int tot1 = 0;
	int tot_1=0;
	bool is = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == -1)tot1++;
		if (a[i] == 1)tot_1++;
		if (tot1 * 2 > i + 1 and is==0) {
			cout << -1 << endl;
			is = 1;
		}
	}
	if (is) {
		syy;
	}
	int tot0 = n - tot1 - tot_1;
	int tmp = tot1 - tot_1; 
	if (tmp > 0) {
		tot0 -= tmp;
		tot_1 += tmp;
	}
	else {
		tmp = -tmp;
		tot0 -= tmp;
		tot1 += tmp;
	}
	int x1, y1, x2, y2;
	x1 = x2 = tot_1+1;
	y1 = y2 = tot_1 + 1 - tot1;
	x1 += (tot0 + 1) / 2;
	if (tot0 & 1)y1 += 1;
	int gd = gcd(x1, y1);
	cout << x1 / gd << " " << y1 / gd << endl;
}


signed main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--) {
		slove();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3632kb

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:

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

result:

wrong answer 1st lines differ - expected: '3 2', found: '5 2'