QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#864748#5652. Controllersjuancs#WA 12ms3808kbC++201.3kb2025-01-20 23:10:322025-01-20 23:10:32

Judging History

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

  • [2025-01-20 23:10:32]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:3808kb
  • [2025-01-20 23:10:32]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef vector<int>vi;
typedef pair<int, int> ii;
typedef tree<int,null_type,less<int>, rb_tree_tag, 
    tree_order_statistics_node_update> ordered_set;

#define el '\n'
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define forn(i,n) for(int i = 0; i < n;++i)
#define pb push_back
#define db(x) cerr << #x << ' ' << x << el;

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll p = 0, neg = 0;
    forn(i, n){
        if(s[i] == '+')++p;
        else ++neg;
    }
    int q;
    cin >> q;
    auto check = [&](ll x, ll y){
        ll xy = x - y;
        ll num = x*neg - y*p;
        if(xy == 0){
            return num == 0;
        }
        if(num % xy != 0)return false;
        ll div = num / xy;
        if(div < 0)return false;
        return div <= p + n;
    };
    forn(_, q){
        ll x, y;
        cin >> x >> y;
        if(check(x, y))cout << "YES" << el;
        else cout << "NO" << el;
    }
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int tt = 1;
    // cin>>tt;
    while(tt--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3712kb

input:

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

output:

YES
YES

result:

ok 2 lines

Test #3:

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

input:

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

output:

NO
YES

result:

ok 2 lines

Test #4:

score: -100
Wrong Answer
time: 12ms
memory: 3808kb

input:

183132
+++-++-+++--+++++-+++---++++++-+-+-+---++++--+++++-+++++-+-+-++-++-++-+++--+++++++-+++++--++-+++-+++-+-++--++++-++++-+++-++++-+-+++++-----+++-++++++++++-++++++++++++++-+++-+-++++---++-++++---+++++++--++++-++++-+-+-+++++-+---+-++++-++++-++-+++++++++-++---++++++++++++-+++-++++++-+++-+-+++++++++...

output:

NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO...

result:

wrong answer 196th lines differ - expected: 'NO', found: 'YES'