提出 #72316880
ソースコード 拡げる
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef queue<int> que;
// ----------------------------------------------------------------------
// https://atcoder.jp/contests/abc173/tasks/abc173_c
// ----------------------------------------------------------------------
int main(void){
int h, w, k;
cin >> h >> w >> k;
vector<string> c(h);
for(int i = 0; i < h; i++) {
cin >> c[i];
}
int ans = 0;
for(int bh = 0; bh < (1 << h); bh++) {
// cout << "----bh:" << bh << endl;
mii mph;
for(int i = 0; i < h; i++) {
if(bh & (1 << i)) {
// cout << i << endl;
mph[i]++;
}
}
auto print = [](string s, mii& mp) {
cout << s;
for(auto m: mp) {
cout << m.first << ": " << m.second << ", ";
}
cout << endl;
};
// print("--H:", mph);
for(int bw = 0; bw < (1 << w); bw++) {
// cout << "----bw:" << bw << endl;
mii mpw;
for(int i = 0; i < w; i++) {
if(bw & (1 << i)) {
// cout << i << endl;
mpw[i]++;
}
}
auto print = [](string s, mii& mp) {
cout << s;
for(auto m: mp) {
cout << m.first << ": " << m.second << ", ";
}
cout << endl;
};
// print("--W:", mpw);
int cnt = 0;
for(int i = 0; i < h; i++) {
if(mph[i]) continue;
for(int j = 0; j < w; j++) {
if(mpw[j]) continue;
cnt += c[i][j] == '#';
}
}
if(cnt == k) ans++;
}
}
cout << ans << endl;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - H and V |
| ユーザ | Yasuki |
| 言語 | C++23 (GCC 15.2.0) |
| 得点 | 300 |
| コード長 | 1709 Byte |
| 結果 | AC |
| 実行時間 | 3 ms |
| メモリ | 3704 KiB |
コンパイルエラー
./Main.cpp: In function 'int main()':
./Main.cpp:56:30: warning: variable 'print' set but not used [-Wunused-but-set-variable]
56 | auto print = [](string s, mii& mp) {
| ^~~~~
./Main.cpp:38:22: warning: variable 'print' set but not used [-Wunused-but-set-variable]
38 | auto print = [](string s, mii& mp) {
| ^~~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | a01.txt, a02.txt, a03.txt, a04.txt |
| All | a01.txt, a02.txt, a03.txt, a04.txt, b05.txt, b06.txt, b07.txt, b08.txt, b09.txt, b10.txt, b11.txt, b12.txt, b13.txt, b14.txt, b15.txt, b16.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| a01.txt | AC | 2 ms | 3600 KiB |
| a02.txt | AC | 1 ms | 3656 KiB |
| a03.txt | AC | 1 ms | 3576 KiB |
| a04.txt | AC | 2 ms | 3608 KiB |
| b05.txt | AC | 1 ms | 3576 KiB |
| b06.txt | AC | 3 ms | 3612 KiB |
| b07.txt | AC | 2 ms | 3544 KiB |
| b08.txt | AC | 2 ms | 3552 KiB |
| b09.txt | AC | 1 ms | 3544 KiB |
| b10.txt | AC | 2 ms | 3544 KiB |
| b11.txt | AC | 3 ms | 3544 KiB |
| b12.txt | AC | 3 ms | 3696 KiB |
| b13.txt | AC | 1 ms | 3552 KiB |
| b14.txt | AC | 1 ms | 3536 KiB |
| b15.txt | AC | 3 ms | 3528 KiB |
| b16.txt | AC | 1 ms | 3704 KiB |