結果

問題 No.3137 Non-Intersect Chord Triangle Game
ユーザー umezo
提出日時 2025-05-03 00:44:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,395 bytes
コンパイル時間 3,589 ms
コンパイル使用メモリ 278,112 KB
実行使用メモリ 13,504 KB
最終ジャッジ日時 2025-05-03 00:44:10
合計ジャッジ時間 7,228 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 65
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;

template<typename T>
struct BIT{
private:
  vector<T> A;
  const int n;
  
public:
  BIT(int _n) : A(_n+1,0), n(_n){}
  
  T sum(int i){
    i++;
    T s=0;
    while(i>0){
      s+=A[i];
      i-=i&-i;
    }
    return s;
  }
  
  T sum(int i,int j){
    return sum(j)-sum(i-1);
  }
  
  void add(int i,T x){
    i++;
    while(i<=n){
      A[i]+=x;
      i+=i&-i;
    }
  }

  void update(int i,T x){
    T tmp=sum(i,i);
    if(tmp!=x) add(i,x-tmp);
  }
};
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,m;
  cin>>n>>m;
  V<int> P(m),Q(m),A(n,-1);
  BIT<int> bit(n);
  rep(i,m){
    cin>>P[i]>>Q[i];
    P[i]--,Q[i]--;
    A[P[i]]=i;
    A[Q[i]]=i;
  }
  if(m==0){
    if(n%4==2) cout<<"Akane"<<endl;
    else cout<<"Aoi"<<endl;
    return 0;
  }
  V<int> pre(m,-1);
  rep(i,n){
    if(A[i]==-1) continue;
    else if(pre[A[i]]==-1) pre[A[i]]=i;
    else{
      auto s=bit.sum(pre[A[i]],i);
      int tmp=i-pre[A[i]]-1-s;
      if(tmp%4==2){
        cout<<"Akane"<<endl;
        return 0;
      }
      bit.add(i,tmp+2);
    }
  }
  int s=bit.sum(0,n-1);
  if((n-s)%4==2) cout<<"Akane"<<endl;
  else cout<<"Aoi"<<endl;
    
  return 0;
}
0