結果
問題 | No.1855 Intersected Lines |
ユーザー |
![]() |
提出日時 | 2021-05-05 11:10:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,722 bytes |
コンパイル時間 | 4,186 ms |
コンパイル使用メモリ | 232,876 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 11:34:40 |
合計ジャッジ時間 | 9,601 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 2 WA * 1 RE * 27 |
ソースコード
//g++ 5.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--) using mint = modint998244353; //n!! mint fac(int n){ if(n<=0){ return 1; } mint res=1; return res*n*fac(n-2); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); mint rr=0,bb=0,rb=0; int n; string s; cin>>n>>s; int r=0,b=0; rep(i,0,2*n){ if(s[i]=='R'){ r++; } else{ b++; } } if(r%2==1){ cout<<0<<endl; return 0; } rep(i,0,2*n){ rep(j,i+1,2*n){ rep(k,j+1,2*n){ rep(l,k+1,2*n){ int r2=0; if(s[i]=='R')r2++; if(s[j]=='R')r2++; if(s[k]=='R')r2++; if(s[l]=='R')r2++; if(r2%2==1)continue; if(r2==2){ if(s[i]==s[j])continue; if(s[j]==s[k])continue; if(s[k]==s[l])continue; if(s[l]==s[i])continue; rb+=fac(r-3)*fac(b-3); } else if(r2==4){ rr+=fac(r-5)*fac(b-1); } else{ bb+=fac(r-1)*fac(b-5); } } } } } mint ans=rr+bb+rb; cout<<ans.val()<<endl; }