QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413805#5652. Controllersthesupermarketisgoingtome#WA 1ms3600kbC++20938b2024-05-18 08:59:452024-05-18 08:59:46

Judging History

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

  • [2024-05-18 08:59:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-05-18 08:59:45]
  • 提交

answer

/*
 * author:  ADMathNoob
 * created: 05/17/24 20:37:58
 * problem: https://qoj.ac/problem/5652
 */

/*
Comments about problem:


*/

#include <bits/stdc++.h>

using namespace std;

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...) 42
#endif

bool Solve(int p, int m, int a, int b) {
  int c = a - b;
  int rhs = (m - p) * b;
  if (rhs == 0) {
    return true;
  }
  if (c == 0) {
    return false;
  }
  if (rhs % c != 0) {
    return false;
  }
  int d = rhs / c;
  return -m <= d && d <= p;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int p = 0, m = 0;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == '+') {
      p += 1;
    } else {
      m += 1;
    }
  }
  int tt;
  cin >> tt;
  while (tt--) {
    int a, b;
    cin >> a >> b;
    cout << (Solve(p, m, a, b) ? "YES" : "NO") << '\n';
  }
  return 0;
}

详细

Test #1:

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

input:

8
+-+---+-
5
2 1
10 3
7 9
10 10
5 3

output:

YES
NO
NO
NO
YES

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

6
+-++--
2
9 7
1 1

output:

YES
YES

result:

ok 2 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3540kb

input:

20
+-----+--+--------+-
2
1000000000 99999997
250000000 1000000000

output:

NO
NO

result:

wrong answer 2nd lines differ - expected: 'YES', found: 'NO'