QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#714064#5420. InscryptionsqrteipiWA 122ms3720kbC++201.7kb2024-11-05 21:29:452024-11-05 21:29:45

Judging History

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

  • [2024-11-05 21:29:45]
  • 评测
  • 测评结果:WA
  • 用时:122ms
  • 内存:3720kb
  • [2024-11-05 21:29:45]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define i128 __int128
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>

#define REP1(a) for (int _ = 0; _ < a; ++_)
#define REP2(i, a) for (int i = 0; i < a; ++i)
#define REP3(i, a, b) for (int i = a; i < b; ++i)
#define REP4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define REP(...) overload4(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__)

#define pb push_back
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> using max_heap = priority_queue<T>;

const int MOD = 1e9+7;
const int INF = 1e18;

int pw(int b, int p) {
  if (p == 0) return 1;
  if (p == 1) return b;
  int k = pw(b, p / 2); k = k * k % MOD;
  if (p % 2 == 0) return k;
  else return k * b % MOD;
}

int32_t main(){
  fast_io;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int arr[n], a = 1, b = 1;
    bool ok = true;
    REP(i, n) {
      cin >> arr[i];
      if (arr[i] >= 0) a++, b++;
      else b--;
      if (b <= 0) ok = false;
    }
    for (int i=n-1; i>=0; i--) if (arr[i] == 0) {
      if (b >= 3) b -= 2, a--;
    }
    if (!ok) cout << "-1\n";
    else {
      int g = gcd(a, b);
      a /= g, b /= g;
      cout << a << " " << b << "\n";
    }
  }
}

詳細信息

Test #1:

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

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: 122ms
memory: 3720kb

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
-1
1
0
1
1
1
1
1
-1
1
0
1
-1
1
-1
1
-1
1
-1
1
0
1
0
1
-1
1
0
1
-1
1
0
1
0
1
0
1
0
1
0
1
-1
1
1
1
0
1
0
1
1
1
0
1
-1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
...

output:

1 1
-1
1 1
1 1
1 1
1 1
-1
-1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
-1
1 1
1 1
-1
1 1
1 1
1 1
-1
1 1
-1
1 1
-1
1 1
1 1
1 1
-1
1 1
-1
-1
-1
-1
1 1
1 1
-1
1 1
-1
1 1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
-1
-1
1 1
1 1
-1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 ...

result:

ok 1000000 lines

Test #3:

score: -100
Wrong Answer
time: 54ms
memory: 3680kb

input:

181249
6
1 0 -1 0 1 0
4
1 -1 -1 -1
8
-1 0 0 0 1 -1 1 1
3
0 1 0
6
1 0 -1 1 -1 0
4
1 -1 -1 -1
9
0 1 0 -1 -1 0 -1 0 1
1
-1
3
0 -1 1
5
0 0 1 -1 1
3
1 -1 0
6
-1 0 0 -1 0 1
8
1 -1 -1 -1 0 1 -1 0
2
0 0
3
-1 1 0
3
0 -1 -1
10
0 1 0 -1 1 1 0 -1 1 0
3
1 0 0
9
1 -1 1 -1 0 -1 0 0 0
3
0 1 0
3
-1 0 0
7
-1 0 -1 -1 ...

output:

4 1
-1
-1
3 2
4 1
-1
3 1
-1
3 2
2 1
3 2
-1
-1
2 1
-1
-1
6 1
3 2
3 1
3 2
-1
-1
-1
-1
2 1
5 3
-1
2 1
2 1
-1
3 2
5 1
1 1
-1
3 2
-1
1 1
-1
2 1
1 1
-1
1 1
-1
1 1
3 2
-1
-1
-1
-1
3 2
5 2
1 1
-1
3 1
-1
-1
1 1
-1
6 1
3 2
-1
3 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'