QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#637873 | #5420. Inscryption | nnk | WA | 151ms | 3892kb | C++20 | 1.6kb | 2024-10-13 14:16:41 | 2024-10-13 14:16:44 |
Judging History
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 (tot0 >= abs(tmp)) {
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: 100
Accepted
time: 0ms
memory: 3892k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