結果
問題 | No.460 裏表ちわーわ |
ユーザー | chaemon |
提出日時 | 2016-12-11 00:19:20 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,621 bytes |
コンパイル時間 | 747 ms |
コンパイル使用メモリ | 85,596 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-05-06 18:04:14 |
合計ジャッジ時間 | 2,240 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 36 ms
6,940 KB |
testcase_06 | AC | 35 ms
6,940 KB |
testcase_07 | AC | 33 ms
6,944 KB |
testcase_08 | AC | 33 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 33 ms
6,944 KB |
testcase_11 | AC | 36 ms
6,940 KB |
testcase_12 | AC | 37 ms
6,944 KB |
testcase_13 | AC | 36 ms
6,940 KB |
testcase_14 | AC | 35 ms
6,944 KB |
testcase_15 | AC | 36 ms
6,940 KB |
testcase_16 | AC | 35 ms
6,940 KB |
testcase_17 | AC | 35 ms
6,944 KB |
testcase_18 | AC | 35 ms
6,940 KB |
testcase_19 | AC | 35 ms
6,940 KB |
testcase_20 | AC | 34 ms
6,940 KB |
testcase_21 | AC | 33 ms
6,940 KB |
testcase_22 | AC | 35 ms
6,944 KB |
testcase_23 | AC | 34 ms
6,944 KB |
testcase_24 | AC | 37 ms
6,940 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
コンパイルメッセージ
main.cpp: In function 'IO& operator<<(IO&, const std::string&)': main.cpp:74:1: warning: no return statement in function returning non-void [-Wreturn-type] 74 | } | ^
ソースコード
// #includes {{{ #include <algorithm> #include <numeric> #include <iostream> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cassert> #include <cstring> #include <cmath> using namespace std; // }}} // pre-written code {{{ #define REP(i,n) for(int i=0;i<(int)(n);++i) #define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) //#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i) #define ALL(c) (c).begin(), (c).end() #define MP make_pair //#define PB push_back #define CLEAR(c,d) memset((c),(d),sizeof(c)) #define TO_STRING(VariableName) # VariableName //#define DB(c) cout<<TO_STRING(c)<<"="<<(c)<<endl #define EXIST(e,s) ((s).find(e)!=(s).end()) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; #define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl; #define clr(a) memset((a),0,sizeof(a)) #define nclr(a) memset((a),-1,sizeof(a)) #define pb push_back typedef long long Int; typedef unsigned long long uInt; typedef long double rn; typedef pair<int,int> pii; //{{{ io struct IO{ }io;//dummy #define endl "\n" IO& operator>>(IO &io,int &n){scanf("%d",&n);return io;} IO& operator>>(IO &io,unsigned int &n){scanf("%u",&n);return io;} IO& operator>>(IO &io,long long &n){scanf("%lld",&n);return io;} IO& operator>>(IO &io,unsigned long long &n){scanf("%llu",&n);return io;} IO& operator>>(IO &io,double &n){scanf("%lf",&n);return io;} IO& operator>>(IO &io,long double &n){scanf("%Lf",&n);return io;} IO& operator>>(IO &io,char *c){scanf("%s",c);return io;} IO& operator>>(IO &io,string &s){ char c;s.clear(); while(isspace(c=getc(stdin))){if(c==-1)return io;} do{ s.push_back(c); }while(!isspace(c=getc(stdin))); if(c!=-1)ungetc(c,stdin); return io; } IO& operator<<(IO &io,const int &n){printf("%d",n);return io;} IO& operator<<(IO &io,const unsigned int &n){printf("%u",n);return io;} IO& operator<<(IO &io,const long long &n){printf("%lld",n);return io;} IO& operator<<(IO &io,const unsigned long long &n){printf("%llu",n);return io;} IO& operator<<(IO &io,const double &n){printf("%lf",n);return io;} IO& operator<<(IO &io,const long double &n){printf("%Lf",n);return io;} IO& operator<<(IO &io,const char c[]){printf("%s",c);return io;} IO& operator<<(IO &io,const string &s){ REP(i,s.size())putc(s[i],stdout); } //}}} // }}} const int INF = 1000000000; int M,N; int a[10][10]; int a2[10][10]; void apply(int i,int j){ REP(i0,3)REP(j0,3){ int s=i+i0-1,t=j+j0-1; if(0<=s and s<M and 0<=t and t<N)a2[s][t]=1-a2[s][t]; } } void write(){ REP(i,M){ REP(j,N){ cout<<a2[i][j]<<" "; } cout<<endl; } cout<<endl; } int main(){ cin>>M>>N; REP(i,M)REP(j,N)cin>>a[i][j]; const int B = (1<<(M+N-1)); int ans0 = INF; REP(b,B){ REP(i,N)REP(j,M)a2[i][j]=a[i][j]; int ans = 0; REP(i,M)if(b&(1<<i))apply(i,0),ans++; REP(j,N-1)if(b&(1<<(M+j)))apply(0,j+1),ans++; // write(); REP(i,M-1)REP(j,N-1){ if(a2[i][j]==1)apply(i+1,j+1),ans++; } bool valid = true; REP(i,M)if(a2[i][N-1]==1)valid = false; REP(j,N)if(a2[M-1][j]==1)valid = false; if(valid){ ans0 = min(ans,ans0); // write(); } } if(ans0==INF)cout<<"Impossible"<<endl; else cout<<ans0<<endl; return 0; }