QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218633#6754. Selectioncurtain_cppWA 6ms3592kbC++143.2kb2023-10-18 16:05:022023-10-18 16:05:02

Judging History

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

  • [2023-10-18 16:05:02]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3592kb
  • [2023-10-18 16:05:02]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
using namespace std;
typedef long long  LL;
typedef unsigned long long uLL;
typedef pair<LL,LL> PII;
const int N = 2e5+10;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1);
#define debug(x) cout<<"[debug]"#x<<"="<<x<<'\n';
template <int T>
struct ModInt {
    const static int MD = T;
    int x;
    ModInt(LL x = 0)
        : x(x % MD) {}
    int get() { return x; }
    ModInt operator+(const ModInt& that) const {
        int x0 = x + that.x;
        return ModInt(x0 < MD ? x0 : x0 - MD);
    }
    ModInt operator-(const ModInt& that) const {
        int x0 = x - that.x;
        return ModInt(x0 < MD ? x0 + MD : x0);
    }
    ModInt operator*(const ModInt& that) const {
        return ModInt((long long)x * that.x % MD);
    }
    ModInt operator/(const ModInt& that) const {
        return *this * that.inverse();
    }
    void operator+=(const ModInt& that) {
        x += that.x;
        if (x >= MD)
            x -= MD;
    }
    void operator-=(const ModInt& that) {
        x -= that.x;
        if (x < 0)
            x += MD;
    }
    void operator*=(const ModInt& that) { x = (long long)x * that.x % MD; }
    void operator/=(const ModInt& that) { *this = *this / that; }
    ModInt inverse() const {
        int a = x, b = MD, u = 1, v = 0;
        while (b) {
            int t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        if (u < 0)
            u += MD;
        return u;
    }
    friend ostream& operator<<(ostream& os, ModInt x) {
        os << x.get();
        return os;
    }
};//全局变量记得清零!
const int mod=998244353;
typedef ModInt<mod> mint;
LL gcd(LL a, LL b)
{
   return b ? gcd(b, a % b) : a;
}
void solve()
{
   int n,m,q;
   cin>>n>>m>>q;
   vector<PII>a(n);
   map<LL,LL>mp;
   vector<PII>g;
   for(int i=0;i<n;i++){
       cin>>a[i].first>>a[i].second;
       mp[i]=a[i].first;
   }
       int cur=m,curpos=-1;
       sort(a.rbegin(),a.rend());
       cur=m;
       for(int i=0;i<n;i++){
           if(a[i].second==1){
               curpos=mp[a[i].first];
               cur--;break;
           }
       }
       //cout<<curpos<<'\n';
   while(q--){
     int op;cin>>op;
     if(op==1){
        int pos,gen;
       cin>>pos>>gen;
       for(int i=0;i<n;i++){
           if(mp[pos-1]==a[i].first){
              a[i].second=gen;
           }
       }
       sort(a.rbegin(),a.rend());
       cur=m;curpos=-1;
       for(int i=0;i<n;i++){
           if(a[i].second==1){
               curpos=mp[a[i].second];
               cur--;break;
           }
       }
     }else{
       int p;cin>>p;
       bool fl=false;
       //cout<<curpos<<" ";
       for(int i=0;i<cur;i++){
           if(mp[p-1]==a[i].first) {
               fl=true;
           }
       }
       if(fl||p-1==curpos) cout<<1<<'\n';
       else cout<<0<<'\n';
     }
   }
}
int main()
{
   ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
   solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2 3
3 0
1 1
2 0
2 2
1 2 0
2 2

output:

1
0

result:

ok 2 number(s): "1 0"

Test #2:

score: -100
Wrong Answer
time: 6ms
memory: 3592kb

input:

1000 1 1000
617 0
199 0
776 0
536 1
258 0
311 1
579 0
844 0
356 1
587 0
564 0
782 0
37 1
717 1
612 1
245 1
444 1
750 0
52 1
92 1
741 0
266 1
71 1
189 1
419 1
580 1
585 1
268 1
255 0
490 1
70 1
497 1
829 1
469 1
641 0
929 1
379 1
507 0
474 1
407 0
221 1
985 0
815 1
217 0
445 1
386 0
132 0
154 0
736 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 69th numbers differ - expected: '1', found: '0'