提出 #59866417
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
const int N = 12;
map<pair<ull, int>, int> mp;
pair<ull, int> tr(vector<int> a, vector<int> b, vector<int> c, int opt) {
ull tr = 0;
for (int i : a) tr = tr * 13331 + i;
tr *= 23337;
for (int i : b) tr = tr * 741123 + i;
tr *= 154154;
for (int i : c) tr = tr * 8585821 + i;
tr *= 23474747;
return {tr, opt};
}
int dfs(vector<int> a, vector<int> b, vector<int> c,int tp) {
// for (int i:a) cerr<<i<<' ';
// cerr<< " | ";
// for (int i:b) cerr<<i<<' ';
// cerr<< " | ";
// for (int i:c) cerr<<i<<' ';
// cerr<< " | ";
// cerr<<'\n';
// cerr << tr(a,b,c,tp).first<<'\n';
if(mp.count(tr(a,b,c,tp))) return mp[tr(a,b,c,tp)];
if (tp==0){
if(a.size()==0){
return 2;
}
// cerr<<"tp=0!"<<a.size()<<'\n';
bool flg=0;
for(int i=0;i<a.size();i++){
vector<int> t1, t2;
t1 = a;
t1.erase(t1.begin()+i);
if(dfs(t1,b,c,tp^1)==2)flg=1;
for(int j=0;j<c.size();j++){
// cerr<<j<<' '<<i<<'\n';
if(c[j]<a[i]){
t1.push_back(c[j]);
t2 = c;
t2.erase(t2.begin()+j);
// cerr<<"tr(a,c):";
// for(int i:t1)cerr<<i<<' ';
// cerr<<'|';
// for(int i:t2)cerr<<i<<' ';
// cerr<<'\n';
if(dfs(t1,b,t2,tp^1)==2)flg=1;
t1.pop_back();
}
}
}
if(flg==0){
mp[tr(a,b,c,tp)] = 2;
return 2;
} else{
mp[tr(a,b,c,tp)] = 1;
return 1;
}
}else{
if(b.size()==0){
return 2;
}
bool flg=0;
for(int i=0;i<b.size();i++){
// cerr<<i<<'\n';
vector<int> t1, t2;
t1 = b;
t1.erase(t1.begin()+i);
if(dfs(a,t1,c,tp^1)==2)flg=1;
for(int j=0;j<c.size();j++){
if(c[j]<b[i]){
t1.push_back(c[j]);
t2 = c;
t2.erase(t2.begin()+j);
if(dfs(a,t1,t2,tp^1)==2)flg=1;
t1.pop_back();
}
}
}
if(flg==0){
mp[tr(a,b,c,tp)] = 2;
return 2;
} else{
mp[tr(a,b,c,tp)] = 1;
return 1;
}
}
}
int main(){
int n,m,l;
vector<int>a,b,c;
cin>>n>>m>>l;
while(n--){
int x;
cin>>x;
a.push_back(x);
}
while(m--){
int x;
cin>>x;
b.push_back(x);
}
while(l--){
int x;
cin>>x;
c.push_back(x);
}
if(dfs(a,b,c,0) == 1) cout << "Takahashi";
else cout<<"Aoki";
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
F - Exchange Game |
| ユーザ |
Nicrobott |
| 言語 |
C++ 20 (gcc 12.2) |
| 得点 |
0 |
| コード長 |
3117 Byte |
| 結果 |
WA |
| 実行時間 |
108 ms |
| メモリ |
6812 KiB |
コンパイルエラー
Main.cpp: In function ‘int dfs(std::vector<int>, std::vector<int>, std::vector<int>, int)’:
Main.cpp:39:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
39 | for(int i=0;i<a.size();i++){
| ~^~~~~~~~~
Main.cpp:45:26: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
45 | for(int j=0;j<c.size();j++){
| ~^~~~~~~~~
Main.cpp:74:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
74 | for(int i=0;i<b.size();i++){
| ~^~~~~~~~~
Main.cpp:81:26: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
81 | for(int j=0;j<c.size();j++){
| ~^~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
hand_01.txt, hand_02.txt, hand_03.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, 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, sample_01.txt, sample_02.txt, sample_03.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| hand_01.txt |
AC |
1 ms |
3500 KiB |
| hand_02.txt |
AC |
1 ms |
3644 KiB |
| hand_03.txt |
AC |
1 ms |
3600 KiB |
| hand_11.txt |
AC |
6 ms |
3772 KiB |
| hand_12.txt |
WA |
6 ms |
3836 KiB |
| hand_13.txt |
AC |
6 ms |
3700 KiB |
| hand_14.txt |
AC |
1 ms |
3512 KiB |
| hand_15.txt |
AC |
1 ms |
3556 KiB |
| hand_16.txt |
AC |
1 ms |
3692 KiB |
| random_01.txt |
AC |
108 ms |
6812 KiB |
| random_02.txt |
AC |
15 ms |
4120 KiB |
| random_03.txt |
WA |
1 ms |
3532 KiB |
| random_04.txt |
AC |
1 ms |
3568 KiB |
| random_05.txt |
AC |
67 ms |
5756 KiB |
| random_06.txt |
AC |
1 ms |
3512 KiB |
| random_07.txt |
AC |
12 ms |
3996 KiB |
| random_08.txt |
WA |
14 ms |
4124 KiB |
| random_09.txt |
AC |
3 ms |
3604 KiB |
| random_10.txt |
AC |
1 ms |
3504 KiB |
| random_11.txt |
AC |
17 ms |
4104 KiB |
| random_12.txt |
AC |
8 ms |
3912 KiB |
| random_13.txt |
AC |
22 ms |
4532 KiB |
| random_14.txt |
AC |
4 ms |
3752 KiB |
| random_15.txt |
AC |
5 ms |
3880 KiB |
| random_16.txt |
WA |
11 ms |
3968 KiB |
| random_17.txt |
WA |
7 ms |
3944 KiB |
| random_18.txt |
WA |
5 ms |
3720 KiB |
| random_19.txt |
WA |
36 ms |
4916 KiB |
| random_20.txt |
AC |
2 ms |
3648 KiB |
| sample_01.txt |
AC |
1 ms |
3512 KiB |
| sample_02.txt |
AC |
24 ms |
4512 KiB |
| sample_03.txt |
AC |
2 ms |
3600 KiB |