Submission #259547

#TimeUsernameProblemLanguageResultExecution timeMemory
259547cheehengFishing Game (RMI19_fishing)C++14
0 / 100
690 ms524292 KiB
#include <bits/stdc++.h> using namespace std; int cnt = 0; void rec(set<int> A, set<int> B, set<int> C, int mode){ if(A.empty() && B.empty() && C.empty()){ cnt ++; return; } if(mode == 0){ if(A.empty()){ rec(A, B, C, 1); }else{ set<int> A2; for(int x: A){ A2.insert(x); } set<int> B2; for(int x: B){ B2.insert(x); } for(int x: A){ A2.erase(x); if(B.find(x) != B.end()){ B2.erase(x); rec(A2, B2, C, 1); B2.insert(x); }else{ B2.insert(x); rec(A2, B2, C, 1); B2.erase(x); } A2.insert(x); } } }else if(mode == 1){ if(B.empty()){ rec(A, B, C, 2); }else{ set<int> B2; for(int x: B){ B.insert(x); } set<int> C2; for(int x: C){ C2.insert(x); } for(int x: B){ B2.erase(x); if(C.find(x) != C.end()){ C2.erase(x); rec(A, B2, C2, 1); C2.insert(x); }else{ C2.insert(x); rec(A, B2, C2, 1); C2.erase(x); } B2.insert(x); } } }else if(mode == 2){ if(C.empty()){ rec(A, B, C, 0); }else{ set<int> C2; for(int x: C){ C.insert(x); } set<int> A2; for(int x: A){ A2.insert(x); } for(int x: C){ C2.erase(x); if(A.find(x) != A.end()){ A2.erase(x); rec(A2, B, C2, 1); A2.insert(x); }else{ A2.insert(x); rec(A2, B, C2, 1); A2.erase(x); } C2.insert(x); } } } } int main(){ int N, T; scanf("%d%d", &N, &T); while(T --){ set<int> A; set<int> B; set<int> C; for(int i = 0; i < 2*N; i ++){ int x; scanf("%d", &x); if(A.count(x)){ A.erase(x); }else{ A.insert(x); } } for(int i = 0; i < 2*N; i ++){ int x; scanf("%d", &x); if(B.count(x)){ B.erase(x); }else{ B.insert(x); } } for(int i = 0; i < 2*N; i ++){ int x; scanf("%d", &x); if(C.count(x)){ C.erase(x); }else{ C.insert(x); } } cnt = 0; rec(A, B, C, 0); printf("%d\n", cnt); } }

Compilation message (stderr)

fishing.cpp: In function 'int main()':
fishing.cpp:98:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &T);
     ~~~~~^~~~~~~~~~~~~~~~
fishing.cpp:107:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
fishing.cpp:117:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
fishing.cpp:127:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...