제출 #1352221

#제출 시각아이디문제언어결과실행 시간메모리
1352221almaarmudAlternating Heights (CCO22_day1problem1)C++20
0 / 25
1096 ms3336 KiB
/*
██████╗  █████╗ ███████╗██╗  ██╗██╗██████╗ 
██╔══██╗██╔══██╗██╔════╝██║  ██║██║██╔══██╗
██████╔╝███████║███████╗███████║██║██║   ██║
██╔══██╗██╔══██║╚════██║██╔══██║██║██║   ██║
██║  ██║██║  ██║███████║██║  ██║██║██████╔╝ 
╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝╚═════╝  
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define ld long double
#define str string
#define ch char
#define db double
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Bob cout<<"Bob\n";
#define Alice cout<<"Alice\n";
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
const ll INF = 10000000000;
void solve(){
    ll n,k,q;
    cin>>n>>k>>q;
    vector<ll>v(n+1);
    for(int i = 1;i<=n;i++){
      cin>>v[i];
    }
    while(q--){
      ll x,y;
      cin>>x>>y;
      vector<pair<ll,ll>>a;
      for(ll i = x;i<y;i++){
        a.pb({v[i],v[i+1]});
      }
      bool ok = true;
      for(ll i = 0;i<a.size();i++){
        ll alma = a[i].ff;
        ll armud = a[i].ss;
        if(alma==armud){
          ok = false;
          break;
        }
        bool flag = (i&1);
        for(ll j = i+1;j<a.size();j++){
          ll pf = a[j].ff;
          ll kh = a[j].ss;
          if(flag and !(j&1)){
            if(alma==pf and armud==kh){
              ok = false;
              break;
            }
          }
          if(!flag and j&1){
            if(alma==pf and armud==kh){
              ok = false;
              break;
            }
          }
        }
        if(!ok)break;
      }
      if(ok){
        YES
      }
      else{
        NO
      }
    }
}
signed main(){
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...