結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-04 05:45:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,017 bytes |
| コンパイル時間 | 368 ms |
| コンパイル使用メモリ | 52,320 KB |
| 最終ジャッジ日時 | 2024-11-14 18:59:02 |
| 合計ジャッジ時間 | 815 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:9: error: ‘vector’ was not declared in this scope
10 | vector<string> a(n);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | #include <string>
main.cpp:10:22: error: expected primary-expression before ‘>’ token
10 | vector<string> a(n);
| ^
main.cpp:10:24: error: ‘a’ was not declared in this scope
10 | vector<string> a(n);
| ^
main.cpp:13:29: error: expected primary-expression before ‘>’ token
13 | vector<pair<int, int>> x;
| ^~
main.cpp:13:32: error: ‘x’ was not declared in this scope
13 | vector<pair<int, int>> x;
| ^
main.cpp:21:27: error: ‘tie’ was not declared in this scope
21 | int p, q; tie(p, q)=x[j];
| ^~~
main.cpp:3:1: note: ‘std::tie’ is defined in header ‘<tuple>’; did you forget to ‘#include <tuple>’?
2 | #include <algorithm>
+++ |+#include <tuple>
3 | #include <string>
main.cpp:29:20: error: expected primary-expression before ‘int’
29 | vector<int> b(n);
| ^~~
main.cpp:30:34: error: ‘b’ was not declared in this scope
30 | for(int i=0;i<n;++i) b[i]=count(begin(a[i]), end(a[i]), 'x');
| ^
main.cpp:31:19: error: ‘b’ was not declared in this scope
31 | int x=b[0];
| ^
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
int n;
while (cin>>n) {
vector<string> a(n);
for(auto& s: a) cin>>s;
vector<pair<int, int>> x;
for(int i=0;i<n;++i) for(int j=i+1;j<n;++j)
if (a[i][j]=='-') x.emplace_back(i, j);
int res=100;
int m=x.size();
for(int i=0;i<(1<<m);++i) {
for(int j=0;j<m;++j) {
int p, q; tie(p, q)=x[j];
if (i&(1<<j)) {
a[p][q]='o'; a[q][p]='x';
}
else {
a[p][q]='x'; a[q][p]='o';
}
}
vector<int> b(n);
for(int i=0;i<n;++i) b[i]=count(begin(a[i]), end(a[i]), 'x');
int x=b[0];
sort(begin(b), end(b));
b.erase(unique(begin(b), end(b)), end(b));
for(int i=0;i<b.size();++i) if (b[i]==x) res=min(res, i+1);
}
cout<<res<<endl;
}
}
hogeover30