QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#349109#8338. Quad Kingdoms Chessucup-team133#WA 95ms3592kbC++173.9kb2024-03-09 23:39:292024-03-09 23:39:30

Judging History

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

  • [2024-03-09 23:39:30]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:3592kb
  • [2024-03-09 23:39:29]
  • 提交

answer

// -fsanitize=undefined,
//#define _GLIBCXX_DEBUG


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <random>
#include <stdio.h>
#include <fstream>
#include <functional>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <chrono>





using namespace std;






#define rep(i,n) for (int i=0;i<n;i+=1)
#define rrep(i,n) for (int i=n-1;i>-1;i--)
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << " )\n";

template<class T>
using vec = vector<T>;
template<class T>
using vvec = vec<vec<T>>;
template<class T>
using vvvec = vec<vvec<T>>;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;


template<class T>
bool chmin(T &a, T b){
  if (a>b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
bool chmax(T &a, T b){
  if (a<b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
T sum(vec<T> x){
  T res=0;
  for (auto e:x){
    res += e;
  }
  return res;
}

template<class T>
void printv(vec<T> x){
  for (auto e:x){
    cout<<e<<" ";
  }
  cout<<endl;
}



template<class T,class U>
ostream& operator<<(ostream& os, const pair<T,U>& A){
  os << "(" << A.first <<", " << A.second << ")";
  return os;
}

template<class T>
ostream& operator<<(ostream& os, const set<T>& S){
  os << "set{";
  for (auto a:S){
    os << a;
    auto it = S.find(a);
    it++;
    if (it!=S.end()){
      os << ", ";
    }
  }
  os << "}";
  return os;
}

template<class T>
ostream& operator<<(ostream& os, const map<int,T>& A){
  os << "map{";
  for (auto e:A){
    os << e.first;
    os << ":";
    os << e.second;
    os << ", ";
  }
  os << "}";
  return os;
}

template<class T>
ostream& operator<<(ostream& os, const vec<T>& A){
  os << "[";
  rep(i,A.size()){
    os << A[i];
    if (i!=A.size()-1){
      os << ", ";
    }
  }
  os << "]" ;
  return os;
}


void solve(){
    int N,M;

    cin>>N;
    vector<int> A(N);
    map<int,int> mp_a;
    set<int> A_max;
    rep(i,N){
        int a;
        cin>>a;
        A[i] = a;
        A_max.insert(a);
        mp_a[a];
        mp_a[a]++;
    }

    cin>>M;
    vector<int> B(M);
    map<int,int> mp_b;
    set<int> B_max;
    rep(i,M){
        int b;
        cin>>b;
        B[i] = b;
        B_max.insert(b);
        mp_b[b];
        mp_b[b]++;
    }

    int Q;
    cin>>Q;
    while (Q--){
        int t,x,y;
        cin>>t>>x>>y;

        if (t == 1){
            int pre_val = A[x-1];
            mp_a[pre_val]--;
            if (mp_a[pre_val] == 0){
                A_max.erase(pre_val);
            }

            A[x-1] = y;
            mp_a[y];
            mp_a[y]++;
            A_max.insert(y);
        }

        else if (t == 2){
            int pre_val = B[x-1];
            mp_b[pre_val]--;
            if (mp_b[pre_val] == 0){
                B_max.erase(pre_val);
            }

            B[x-1] = y;
            mp_b[y];
            mp_b[y]++;
            B_max.insert(y);
        }

        //debug(A);
        //debug(B);
        //debug(*A_max.rbegin());
        //debug(*B_max.rbegin());

        if (*A_max.rbegin() == *B_max.rbegin()){
            int Max_val = *A_max.rbegin();
            if (mp_a[Max_val] == mp_b[Max_val]){
                cout << "YES" << "\n";
            }
            else{
                cout << "NO" << "\n";
            }
        }
        else{
            cout << "NO" << "\n";
        }
    }



}


int main(){

    int T;
    T = 1;
    while (T--){
        solve();
    }

    
    

    
}

詳細信息

Test #1:

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

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: 95ms
memory: 3592kb

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
YES
YES
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
...

result:

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