寝癖頭の解法

学習中の覚え書きを投稿、更新していきます。

AtCoder Problems in C++ #B - Yellow and Red Card

AtCoder Beginner Contestの過去問から、その提出コードの解答例です。
AtCoderとは、コンテストを通じて、プログラミングやアルゴリズムを学習するサービスです。
atcoder.jp
プログラミングコンテストとは、「与えられた問題をいかに素早く、正確に」解くことができるかを競うものです。
競技プログラミング」を略して、「競プロ」などと呼ばれています。

#B - Yellow and Red Card

atcoder.jp

僕が作成、提出したコードは、以下のとおりです。

/*
AtCoder Problems in C++
#B - Yellow and Red Card
https://atcoder.jp/contests/abc292/tasks/abc292_b
提出コードの解答例
https://neguse-atama.hatenablog.com
*/
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll n,q;
  cin>>n>>q;
  vector<pair<ll,ll>> v(n+1,{0,0});
  for(ll i=0;i<q;i++){
    ll e,x;
    cin>>e>>x;
    if(e==1){
      v[x].first++;
    }else if(e==2){
      v[x].second++;
    }else{
      if(v[x].first==2 || v[x].second==1){
        cout<<"Yes\n";
      }else{
        cout<<"No\n";
      }
    }
  }
  return 0;
}

AtCoder Beginner Contestは、オンラインジャッジによるプログラミングコンテストです。
日本語と英語に対応していて、週末ごとに実施されているみたいです。
https://practice.contest.atcoder.jp/tutorial
アカウントを登録すれば、誰でも参加できます。