結果

問題 No.1717 Levi-Civita Triangle
ユーザー 蜜蜂蜜蜂
提出日時 2021-10-22 21:55:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,331 bytes
コンパイル時間 4,008 ms
コンパイル使用メモリ 231,864 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 13:01:21
合計ジャッジ時間 5,952 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 9 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 6 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 30 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 23 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 10 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 33 ms
4,348 KB
testcase_33 AC 39 ms
4,348 KB
testcase_34 AC 39 ms
4,348 KB
testcase_35 AC 40 ms
4,348 KB
testcase_36 AC 40 ms
4,348 KB
testcase_37 AC 40 ms
4,348 KB
testcase_38 AC 40 ms
4,348 KB
testcase_39 AC 38 ms
4,348 KB
testcase_40 AC 39 ms
4,348 KB
testcase_41 AC 40 ms
4,348 KB
testcase_42 AC 40 ms
4,348 KB
testcase_43 AC 40 ms
4,348 KB
testcase_44 AC 40 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//g++ 1.cpp -std=c++14 -O2 -I .
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;

#define fi first
#define se second
#define pb push_back
#define pq_big(T) priority_queue<T,vector<T>,less<T>>
#define pq_small(T) priority_queue<T,vector<T>,greater<T>>
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())

vvll com(3,vll(3));
 
ll COM(int n,int k){
  if(k==0)return 1;
  ll x=1;
  rep(i,0,100){
    int a=n%3,b=k%3;
    x*=com[a][b];
    n/=3,k/=3;
  }
  return x%3;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  com[0][0]=1,com[0][1]=0,com[0][2]=0;
  com[1][0]=1,com[1][1]=1,com[1][2]=0;
  com[2][0]=1,com[2][1]=2,com[2][2]=1;

  int n;
  cin>>n;

  vi a(2*n+1);
  rep(i,0,2*n+1){
    cin>>a[i];
  }

  rep(i,0,2*n){
    if(a[i]==a[i+1]){
      cout<<0<<endl;
      return 0;
    }
  }

  int ans=0;
  rep(i,0,n+1){
    int nw=a[2*i];
    nw*=1+i%2;
    nw*=COM(n,i);
    ans+=nw%3;
  }

  cout<<ans%3<<endl;
}
0