답안 #494093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494093 2021-12-14T10:14:25 Z Jeff12345121 Fishing Game (RMI19_fishing) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define sz(z) ( (int)z.size() )
#define in cin
#define out cout
using namespace std;

ifstream in("in.in");
ofstream out("out.out");

const int mod = 1000000007;
int n,sol = 0;

bool discard(vector<int> &v) {
    bool eliminated = false;
    for (int i = 0; i + 1 < sz(v); i++) {
        for (int j = i + 1; j < sz(v); j++) {
            if (v[i] == v[j]) {
                swap(v[j] , v[(int)v.size() - 1]);
                v.pop_back();

                swap(v[i] , v[(int)v.size() - 1]);
                v.pop_back();

                eliminated = true;
            }
        }
    }
    return eliminated;
}

void back(int round, vector<vector<int>> v, bool eliminated) {
    int mround = round % 3;
    if ( v[0].empty() && v[1].empty() && v[2].empty()  ) {
       sol++;
       return;
    }
    if (mround == 0 && !eliminated) {
        return;
    }


    if (mround == 0) eliminated = false;

    int l = mround, r = (mround + 1) % 3;

    if (v[l].empty() ) {
        back(round + 1 , v , eliminated);
    } else {
        for (int i = 0; i < v[l].size(); i++) {
            vector<vector<int>> newv = {v[0] , v[1] , v[2]};
            int x = newv[l][i];
            swap(newv[l][i] , newv[l][(int)newv[l].size() - 1]);
            newv[l].pop_back();
            newv[r].push_back(x);
            int newEliminated = max(discard(newv[r]) , eliminated);
            back(round + 1, newv, newEliminated);
        }
    }
  //  cout << "\n";
}


int main() {
    int t;

    in >> n >> t;
    while (t--) {
        vector<vector<int>> v(3);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 2 * n; j++) {
                int x;
                in >> x;
                v[i].push_back(x);
            }
        }

        sol = 0;
        for (int i = 0; i < 3; i++) discard(v[i]);
        back(0 , v , 1);
       // cout << "\n";
        out << sol % mod << "\n";

    }

    return 0;
}

Compilation message

fishing.cpp: In function 'void back(int, std::vector<std::vector<int> >, bool)':
fishing.cpp:49:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (int i = 0; i < v[l].size(); i++) {
      |                         ~~^~~~~~~~~~~~~
fishing.cpp: In function 'int main()':
fishing.cpp:3:12: error: reference to 'cin' is ambiguous
    3 | #define in cin
      |            ^~~
fishing.cpp:66:5: note: in expansion of macro 'in'
   66 |     in >> n >> t;
      |     ^~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from fishing.cpp:1:
/usr/include/c++/10/iostream:60:18: note: candidates are: 'std::istream std::cin'
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
fishing.cpp:3:12: note:                 'std::ifstream cin'
    3 | #define in cin
      |            ^~~
fishing.cpp:7:10: note: in expansion of macro 'in'
    7 | ifstream in("in.in");
      |          ^~
fishing.cpp:3:12: error: reference to 'cin' is ambiguous
    3 | #define in cin
      |            ^~~
fishing.cpp:72:17: note: in expansion of macro 'in'
   72 |                 in >> x;
      |                 ^~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from fishing.cpp:1:
/usr/include/c++/10/iostream:60:18: note: candidates are: 'std::istream std::cin'
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
fishing.cpp:3:12: note:                 'std::ifstream cin'
    3 | #define in cin
      |            ^~~
fishing.cpp:7:10: note: in expansion of macro 'in'
    7 | ifstream in("in.in");
      |          ^~
fishing.cpp:4:13: error: reference to 'cout' is ambiguous
    4 | #define out cout
      |             ^~~~
fishing.cpp:81:9: note: in expansion of macro 'out'
   81 |         out << sol % mod << "\n";
      |         ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from fishing.cpp:1:
/usr/include/c++/10/iostream:61:18: note: candidates are: 'std::ostream std::cout'
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
fishing.cpp:4:13: note:                 'std::ofstream cout'
    4 | #define out cout
      |             ^~~~
fishing.cpp:8:10: note: in expansion of macro 'out'
    8 | ofstream out("out.out");
      |          ^~~