結果
問題 | No.43 野球の試合 |
ユーザー | evawenis |
提出日時 | 2020-07-09 17:48:59 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,033 bytes |
コンパイル時間 | 2,690 ms |
コンパイル使用メモリ | 213,008 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-04-16 19:01:38 |
合計ジャッジ時間 | 3,217 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | WA | - |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/algorithm:60, from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/x86_64-pc-linux-gnu/bits/stdc++.h:51, from main.cpp:1: In function 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]', inlined from 'int main()' at main.cpp:45:11: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:238:7: warning: 'tans' may be used uninitialized [-Wmaybe-uninitialized] 238 | if (__b < __a) | ^~ main.cpp: In function 'int main()': main.cpp:39:29: note: 'tans' was declared here 39 | int tans; | ^~~~
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ cin.tie(0),ios::sync_with_stdio(false); int n; cin>>n; vector<string>s(n); for(auto&&i:s)cin>>i; vector<pair<int,int>>sc(n,{0,-1}); sc.at(0).second=0; for(int i=1;i<n;++i){ if(s.at(0).at(i)=='x'){ ++sc.at(i).first; continue; } if(s.at(0).at(i)=='-'){ s.at(0).at(i)='o'; s.at(i).at(0)='x'; } ++sc.at(0).first; } for(int y=1;y<n;++y){ for(int x=1;x<n;++x){ if(s.at(y).at(x)=='#')break; if(s.at(y).at(x)!='x')++sc.at(y).first; } } int ans=n+1; for(int i=0,lim=n-1;i<(1<<lim);++i){ for(int j=0;j<(1<<lim);++j){ vector<pair<int,int>>tsc=sc; for(int y=0;y<lim;++y){ if(!(i&(1<<y)))continue; for(int x=0;x<lim;++x){ if(!(j&(1<<x))||x<=y||s.at(y+1).at(x+1)!='-')continue; ++tsc.at(y+1).first; --tsc.at(x+1).first; } } stable_sort(tsc.rbegin(),tsc.rend()); int tans; for(int k=0;k<n;++k){ if(tsc.at(k).second==0){ tans=k+1; } } ans=min(ans,tans); } } cout<<ans<<"\n"s; }