Submission #36107290


Source Code Expand

#include <bits/stdc++.h>
#include<atcoder/maxflow>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(int)n;i++)
int read(){int r;scanf("%d",&r);return r;}
char s[310][310];
int main(){
  int h=read();
  int w=read();
  rep(i,0,h)scanf("%s",s[i]);
  auto x=vector(h,vector(w,0)); // 以首个为行标识
  auto y=vector(h,vector(w,0)); // 以首个+hw为列标识
  const int S=2*h*w;
  const int T=S+1;
  atcoder::mf_graph<int>g(T+1);
  rep(i,0,h)rep(j,0,w)if(s[i][j]=='.'){
    int curi=i*w+j;
    int curj=curi+h*w;
    x[i][j]=(i&&s[i-1][j]=='.')?x[i-1][j]:curi;
    y[i][j]=(j&&s[i][j-1]=='.')?y[i][j-1]:curj;
    if(x[i][j]==curi)g.add_edge(S,curi,1);
    if(y[i][j]==curj)g.add_edge(curj,T,1);
    g.add_edge(x[i][j],y[i][j],1000000000);
  }
  printf("%d\n",g.flow(S,T));
}

Submission Info

Submission Time
Task G - Security Camera 3
User cromarmot
Language C++ (GCC 9.2.1)
Score 600
Code Size 787 Byte
Status AC
Exec Time 55 ms
Memory 14680 KiB

Compile Error

./Main.cpp: In function ‘int read()’:
./Main.cpp:5:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    5 | int read(){int r;scanf("%d",&r);return r;}
      |                  ~~~~~^~~~~~~~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:10:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   10 |   rep(i,0,h)scanf("%s",s[i]);
      |             ~~~~~^~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 15 ms 7132 KiB
random_02.txt AC 19 ms 7788 KiB
random_03.txt AC 15 ms 7732 KiB
random_04.txt AC 4 ms 4052 KiB
random_05.txt AC 17 ms 7612 KiB
random_06.txt AC 4 ms 4192 KiB
random_07.txt AC 25 ms 7628 KiB
random_08.txt AC 17 ms 6556 KiB
random_09.txt AC 55 ms 13916 KiB
random_10.txt AC 36 ms 9480 KiB
random_11.txt AC 32 ms 10020 KiB
random_12.txt AC 17 ms 6540 KiB
random_13.txt AC 37 ms 14312 KiB
random_14.txt AC 3 ms 3760 KiB
random_15.txt AC 21 ms 7588 KiB
random_16.txt AC 4 ms 3896 KiB
random_17.txt AC 31 ms 13820 KiB
random_18.txt AC 2 ms 3784 KiB
random_19.txt AC 2 ms 3756 KiB
random_20.txt AC 2 ms 3676 KiB
random_21.txt AC 22 ms 14680 KiB
random_22.txt AC 23 ms 14184 KiB
random_23.txt AC 30 ms 14076 KiB
random_24.txt AC 25 ms 13892 KiB
random_25.txt AC 23 ms 13544 KiB
random_26.txt AC 22 ms 13000 KiB
random_27.txt AC 10 ms 8572 KiB
random_28.txt AC 5 ms 5276 KiB
sample_01.txt AC 2 ms 3564 KiB
sample_02.txt AC 2 ms 3588 KiB
sample_03.txt AC 3 ms 3892 KiB