Submission #1131293


Source Code Expand

// @author peter50216
// lots of default code (especially dump/R/W) borrowed from shik, thanks!
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// {{{ custom namespace, to avoid name collision.
// stupid macro so that vim doesn't get one more indent...
#define MYSPACE namespace zone_of_peter50216{
#define MYSPACE_END }

MYSPACE
// }}}
// #defines & template magics {{{
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i,n) for (int i=0; i<(n); i++ )
#define REP1(i,a,b) for (int i=(a); i<=(b); i++ )
#define PER(i,n) for (int i=(n)-1; i>=0; i--)
#define PER1(i,a,b) for (int i=(a); i>=(b); i--)
#define FOR(it,c) for (auto it=(c).begin(); it!=(c).end(); it++)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
  int c=0;
  while ( *s!=',' || c!=0 ) {
    if ( *s=='(' || *s=='[' || *s=='{' ) c++;
    if ( *s==')' || *s==']' || *s=='}' ) c--;
    cerr<<*s++;
  }
  cerr<<"="<<head<<", ";
  _dump(s+1,tail...);
}

#define dump(...) do { \
  fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
  _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
  s<<"[";
  for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
  s<<"]";
  return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
template<typename T>
void _R( vector<T>& v ) {
  size_t s; scanf("%zu", &s);
  v.resize(s);
  for (size_t i = 0; i < s; i++) _R(v[i]);
}

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
  _R(head);
  R(tail...);
}

#define DRI(...) int __VA_ARGS__; R(__VA_ARGS__)
#define CASET int t; R(t); for(int cas=1; cas<=t; cas++)

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
  for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
    if ( i!=x.cbegin() ) putchar(' ');
    _W(*i);
  }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
  _W(head);
  putchar(sizeof...(tail)?' ':'\n');
  W(tail...);
}

inline string ssprintf(const char* format, ...) {
  static char buf[1000000]; // who cares about buffer overflow :P
  va_list args;
  va_start(args, format);
  vsprintf(buf, format, args);
  va_end(args);
  return buf;
}

// }}}

char in[510][510];
int cnt[510];
int used[510];
int main(int argc, char* argv[]) {
  DRI(n);
  int tc=0;
  REP(i,n){
    R(in[i]);
    REP(j,n){
      if(in[i][j]=='#'){
        tc++;
        cnt[i]++;
        used[j]++;
      }
    }
  }
  if(tc==0){
    puts("-1");
    return 0;
  }
  int ans=100000;
  REP(i,n){
    int u=n-cnt[i];
    if(!used[i])u++;
    REP(j,n)if(in[i][j]=='.'||used[j]!=n)u++;
    ans=min(ans,u);
  }
  W(ans);
  return 0;
}

// {{{ END
MYSPACE_END
int main(int argc, char* argv[]) { return zone_of_peter50216::main(argc,argv); }
// }}}
// vim: fdm=marker:commentstring=\ \"\ %s:nowrap:autoread

Submission Info

Submission Time
Task B - Row to Column
User peter50216
Language C++14 (GCC 5.4.1)
Score 1300
Code Size 4274 Byte
Status AC
Exec Time 4 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘void zone_of_peter50216::_R(int&)’:
./Main.cpp:76:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R( int &x ) { scanf("%d",&x); }
                                   ^
./Main.cpp: In function ‘void zone_of_peter50216::_R(int64_t&)’:
./Main.cpp:77:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R( int64_t &x ) { scanf("%" PRId64,&x); }
                                             ^
./Main.cpp: In function ‘void zone_of_peter50216::_R(double&)’:
./Main.cpp:78:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R( double &x ) { scanf("%lf",&x); }
                                       ^
./Main.cpp: In function ‘void zone_of_peter50216::_R(char&)’:
./Main.cpp:79:37: warning: ignoring return value of ‘int scanf(const char*, ...)’...

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 300 / 300 1000 / 1000
Status
AC × 5
AC × 20
AC × 43
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt
Subtask 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
0_04.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt AC 1 ms 256 KB
1_04.txt AC 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt AC 1 ms 256 KB
1_07.txt AC 1 ms 256 KB
1_08.txt AC 1 ms 256 KB
1_09.txt AC 1 ms 256 KB
1_10.txt AC 1 ms 256 KB
1_11.txt AC 1 ms 256 KB
1_12.txt AC 1 ms 256 KB
1_13.txt AC 1 ms 256 KB
1_14.txt AC 1 ms 256 KB
2_00.txt AC 2 ms 512 KB
2_01.txt AC 3 ms 512 KB
2_02.txt AC 2 ms 512 KB
2_03.txt AC 2 ms 512 KB
2_04.txt AC 2 ms 512 KB
2_05.txt AC 2 ms 512 KB
2_06.txt AC 2 ms 512 KB
2_07.txt AC 3 ms 512 KB
2_08.txt AC 4 ms 512 KB
2_09.txt AC 3 ms 512 KB
2_10.txt AC 3 ms 512 KB
2_11.txt AC 4 ms 512 KB
2_12.txt AC 4 ms 512 KB
2_13.txt AC 3 ms 512 KB
2_14.txt AC 3 ms 512 KB
2_15.txt AC 2 ms 512 KB
2_16.txt AC 2 ms 512 KB
2_17.txt AC 2 ms 512 KB
2_18.txt AC 2 ms 384 KB
2_19.txt AC 3 ms 512 KB
2_20.txt AC 2 ms 512 KB
2_21.txt AC 2 ms 384 KB
2_22.txt AC 3 ms 512 KB