QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#346410#8338. Quad Kingdoms Chessucup-team055#WA 108ms3788kbC++201.5kb2024-03-08 14:41:242024-03-08 14:41:25

Judging History

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

  • [2024-03-08 14:41:25]
  • 评测
  • 测评结果:WA
  • 用时:108ms
  • 内存:3788kb
  • [2024-03-08 14:41:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define all(p) p.begin(),p.end()
using ll =long long;

template <class T> struct segtree {
    vector<T> t;
    vector<int> buf;
    segtree(int n) : t(2 * n), buf() {}
    void set(int i, T x) {
        i += t.size() / 2;
        t[i] = x;
        while (i /= 2) {
            t[i] = t[i * 2] + t[i * 2 + 1];
        }
    }
    T get(int l, int r) {
        T al, ar;
        l += t.size() / 2, r += t.size() / 2;
        while (l < r) {
            if (l & 1)
                al = al + t[l++];
            l >>= 1;
            if (r & 1)
                ar = t[--r] + ar;
            r >>= 1;
        }
        return al + ar;
    }
};

struct F{
    int val=-1;
    int cou=0;
    F operator+(F a){
        if(a.val>val) return a;
        if(a.val==val) cou+=a.cou;
        return *this;
    }
};

void solve(){
    int N;
    cin>>N;
    segtree<F> seg1(N);
    rep(i,0,N){
        int a;
        cin>>a;
        seg1.set(i,{a,1});
    }
    int M;
    cin>>M;
    segtree<F> seg2(M);
    rep(i,0,M){
        int a;
        cin>>a;
        seg2.set(i,{a,1});
    }
    int Q;
    cin>>Q;
    while(Q--){
        int t,x,y;
        cin>>t>>x>>y;
        x--;
        if(t==1) seg1.set(x,{y,1});
        if(t==2) seg2.set(x,{y,1});
        auto tmp1=seg1.t[1];
        auto tmp2=seg2.t[1];
        cout<<(tmp1.val==tmp2.val&&tmp1.cou==tmp2.cou?"YES\n":"NO\n");
    }
}

int main(){
    solve();
}

詳細信息

Test #1:

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

input:

5
1 2 3 4 5
5
5 4 3 2 1
8
1 1 5
1 4 2
1 2 4
1 5 1
1 5 5
2 1 4
2 3 5
2 5 5

output:

NO
NO
NO
YES
NO
NO
NO
YES

result:

ok 8 tokens

Test #2:

score: -100
Wrong Answer
time: 108ms
memory: 3560kb

input:

1
2
6
2 1 1 1 1 1
200000
2 6 2
1 1 1
1 1 1
1 1 2
2 1 1
1 1 2
1 1 1
2 4 1
2 1 2
1 1 1
1 1 2
2 5 1
1 1 1
1 1 2
1 1 1
2 6 1
1 1 2
1 1 2
1 1 2
2 3 1
1 1 1
2 1 1
2 6 2
1 1 2
2 4 1
1 1 2
2 6 1
1 1 2
1 1 1
2 5 2
2 6 2
1 1 1
2 4 2
2 5 2
2 6 2
1 1 1
2 5 1
2 6 2
1 1 2
1 1 1
1 1 1
2 4 1
1 1 2
1 1 2
1 1 2
2 3 2...

output:

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

result:

wrong answer 5th words differ - expected: 'YES', found: 'NO'