結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
ococonomy1
|
| 提出日時 | 2024-03-31 13:36:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,137 bytes |
| コンパイル時間 | 1,005 ms |
| コンパイル使用メモリ | 109,376 KB |
| 最終ジャッジ日時 | 2025-02-20 16:22:31 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'
#define MULTI_TEST_CASE false
void solve(void){
//問題を見たらまず「この問題設定から言えること」をいっぱい言う
//一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
//添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
//ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
//よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
int h,w;
cin >> h >> w;
vector<string> s(h);
for(int i = 0; i < h; i++)cin >> s[i];
vector<int> v(h + w - 2,0);
for(int i = h - 1; i < h + w - 2; i++)v[i] = 1;
int ans = 0;
do{
int x = 0,y = 0;
int jew = 1;
bool dame = false;
for(int i = 0; i < h + w - 2; i++){
if(!v[i])x++;
else y++;
if(s[x][y] == '#')dame = true;
if(s[x][y] == 'o')jew++;
else jew--;
if(jew < 0)dame = true;
if(dame)break;
}
if(!dame)ans++;
}while(next_permutation(v.begin(),v.end()));
cout << ans << El;
return;
}
void calc(void){
return;
}
signed main(void){
cin.tie(nullptr);
ios::sync_with_stdio(false);
calc();
int t = 1;
if(MULTI_TEST_CASE)cin >> t;
while(t--){
solve();
}
return 0;
}
ococonomy1