Submission #17715944


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<char>>;


int main()
{
  ll h,w,k;
  cin >> h >> w >> k;
  Graph G(h,vector<char> (w));

  REP(i,h){
    REP(j,w){
      cin >> G.at(i).at(j);
    }
  }

  ll answer = 0;

  for (int bit = 0; bit < (1<<h+w); ++bit) {
    Graph g = G;
    vector<int> S;
    for (int i = 0; i < h+w; ++i) {
      if (bit & (1<<i)) { // 列挙に i が含まれるか
          S.push_back(i);
      }
    }

    REP(i,S.size()){
      if(S.at(i)<h){
        REP(j,w){
          g.at(S.at(i)).at(j) = '.';
        }
      }else{
        int rnum = S.at(i)-h;
        REP(j,h){
          g.at(j).at(rnum) = '.';
        }
      }
    }

    ll count=0;
    REP(i,h){
      REP(j,w){
        if(g.at(i).at(j)=='#'){
          count++;
        }
      }
    }
    if(count==k){
      answer++;
    }
  }

  cout << answer << endl;


}

Submission Info

Submission Time
Task C - H and V
User takkey
Language C++ (GCC 9.2.1)
Score 300
Code Size 1354 Byte
Status AC
Exec Time 10 ms
Memory 3648 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:32: warning: suggest parentheses around ‘+’ inside ‘<<’ [-Wparentheses]
   34 |   for (int bit = 0; bit < (1<<h+w); ++bit) {
      |                               ~^~
./Main.cpp:10:30: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   10 | #define REP(i,n) for(ll i=0;i<n;i++)
......
   43 |     REP(i,S.size()){
      |         ~~~~~~~~~~            
./Main.cpp:43:5: note: in expansion of macro ‘REP’
   43 |     REP(i,S.size()){
      |     ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 16
Set Name Test Cases
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
Case Name Status Exec Time Memory
a01.txt AC 7 ms 3436 KiB
a02.txt AC 3 ms 3580 KiB
a03.txt AC 2 ms 3608 KiB
a04.txt AC 9 ms 3536 KiB
b05.txt AC 2 ms 3556 KiB
b06.txt AC 8 ms 3508 KiB
b07.txt AC 6 ms 3556 KiB
b08.txt AC 6 ms 3648 KiB
b09.txt AC 2 ms 3480 KiB
b10.txt AC 8 ms 3560 KiB
b11.txt AC 10 ms 3508 KiB
b12.txt AC 9 ms 3508 KiB
b13.txt AC 2 ms 3424 KiB
b14.txt AC 2 ms 3440 KiB
b15.txt AC 6 ms 3448 KiB
b16.txt AC 2 ms 3480 KiB