Submission #9687608


Source Code Expand

Copy
#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<ll>c(N,0);
  ll ans=1;
  for(int i=0;i<N;i++){
    c[A[i]]++;
    if(A[i]==0)ans=(ans*(4-c[0]))%MOD;
    else ans=(ans*(c[A[i]-1]-c[A[i]]+1))%MOD;
  }
  cout<<(ans)%MOD<<endl;
  return 0;
}

Submission Info

Submission Time
Task E - Colorful Hats 2
User reg7777
Language C++14 (GCC 5.4.1)
Score 500
Code Size 593 Byte
Status
Exec Time 10 ms
Memory 1792 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 500 / 500 in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in59.txt, in61.txt, in62.txt, in63.txt, in64.txt, in65.txt, in66.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
in01.txt 1 ms 256 KB
in02.txt 10 ms 1792 KB
in03.txt 1 ms 256 KB
in04.txt 1 ms 256 KB
in05.txt 10 ms 1792 KB
in06.txt 9 ms 1792 KB
in07.txt 10 ms 1792 KB
in08.txt 10 ms 1792 KB
in09.txt 1 ms 256 KB
in10.txt 10 ms 1792 KB
in11.txt 1 ms 256 KB
in12.txt 1 ms 256 KB
in13.txt 9 ms 1792 KB
in14.txt 9 ms 1792 KB
in15.txt 10 ms 1792 KB
in16.txt 10 ms 1792 KB
in17.txt 9 ms 1792 KB
in18.txt 8 ms 1792 KB
in19.txt 1 ms 256 KB
in20.txt 1 ms 256 KB
in21.txt 2 ms 512 KB
in22.txt 9 ms 1792 KB
in23.txt 9 ms 1792 KB
in24.txt 9 ms 1792 KB
in59.txt 1 ms 256 KB
in61.txt 1 ms 256 KB
in62.txt 1 ms 256 KB
in63.txt 1 ms 256 KB
in64.txt 1 ms 256 KB
in65.txt 1 ms 256 KB
in66.txt 1 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB