結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
kaityo_17
|
| 提出日時 | 2024-03-31 13:54:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 3,083 bytes |
| コンパイル時間 | 3,539 ms |
| コンパイル使用メモリ | 230,736 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 18:37:12 |
| 合計ジャッジ時間 | 4,359 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define yes (cout << "Yes" << endl)
#define YES (cout << "YES" << endl)
#define no (cout << "No" << endl)
#define NO (cout << "NO" << endl)
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using Graph = vector<vector<int>>;
const int mod = 998244353;
const int MOD = 1000000007;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,1,0,-1};
ll chmin(ll a,ll b) {
if(a < b) return a;
else return b;
}
void O(vector<int> v) {
rep(i,0,v.size()) {
cout << v[i] << " ";
}
cout << endl;
}
void O(vector<string> v) {
rep(i,0,v.size()) cout << v[i] << endl;
cout << endl;
}
void O(int a) {
cout << a << endl;
}
void O(ll a) {
cout << a << endl;
}
void O(string s) {
cout << s << endl;
}
struct unionfind {
vector<int> data;
unionfind(int size) : data(size, -1) { }
bool unite(int x, int y) {
x = root(x); y = root(y);
if (x != y) {
if (data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
return x != y;
}
bool same(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
return data[x] < 0 ? x : data[x] = root(data[x]);
}
int size(int x) {
return -data[root(x)];
}
};
ll gcd(ll a, ll b) {
a = abs(a); b = abs(b);
if (a < b)swap(a, b);
while (b) {
ll r = a % b; a = b; b = r;
}
return a;
}
//x,yがax+by=gcd(a,b)の解になる x,yが格納
ll extgcd(ll a, ll b, ll& x, ll& y) {
ll d = a;
if (b != 0) {
d = extgcd(b, a % b, y, x);
y -= (a / b) * x;
}
else {
x = 1; y = 0;
}
return d;
}
ll pow(ll a,ll b) {
ll ans = 1;
rep(i,0,b) ans *= a;
return ans;
}
int main() {
int h,w;
cin >> h >> w;
int a[h][w];
rep(i,0,h) rep(j,0,w) {
char c;
cin >> c;
if(c == 'o') {
a[i][j] = 1;
}
else if(c == '#') a[i][j] = 0;
else a[i][j] = -1;
}
int v[h + w - 2];
rep(i,0,h - 1) v[i] = 3;
rep(i,0,w - 1) v[i + h - 1] = 4;
/*rep(i,0,h + w - 2) cout << v[i] << " ";
cout << endl;
*/
ll ans = 0;
do{
int cnt = 1;
int nowx = 0;
int nowy = 0;
bool ok = true;
rep(i,0,h + w - 2) {
if(v[i] == 3) {
nowx++;
}
else nowy++;
//cout << nowx << " " << nowy << endl;
cnt += a[nowx][nowy];
if(cnt <= -1) {
ok = false;
}
if(a[nowx][nowy] == 0) {
ok = false;
}
}
//cout << endl;
if(ok) ans++;
}while(next_permutation(v,v + h + w - 2));
cout << ans << endl;
}
kaityo_17