답안 #347445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
347445 2021-01-13T05:21:58 Z ijxjdjd Fishing Game (RMI19_fishing) C++14
0 / 100
268 ms 524292 KB
#include <bits/stdc++.h>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)
using namespace std;

using ll = long long;
ll MOD = (int)(1e9) + 7;
const int MAXN = 305;
ll dp[MAXN][MAXN][MAXN][3];
ll fill(int a, int b, int c, int d) {
    if (a == 0 && b == 0 && c == 0) {
        return 1;
    }
    if (a < 0 || b < 0 || c < 0 || d >= 3) {
        return 0;
    }
    if (dp[a][b][c][d] != -1) {
        return dp[a][b][c][d];
    }
    else {
        dp[a][b][c][d] = a*fill(b, c, a-1, 0) + c*fill(b+1, c-1, a, d+1);
        dp[a][b][c][d] %= MOD;
        return dp[a][b][c][d];
    }
}
int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	FR(i, MAXN) {
        FR(j, MAXN) {
            FR(k, MAXN) {
                FR(z, 3) {
                    dp[i][j][k][z] = -1;
                }
            }
        }
    }
	int T;
	int N;
	cin >> N;
	cin >> T;
	while (T-->0) {
        vector<int> vecs[3];
        FR(j, 3) {
            FR(i, 2*N) {
                int a;
                cin >> a;
                auto it = find(all(vecs[j]), a);
              if (it == vecs[j].end()) {
                vecs[j].push_back(a);
              }
            }
        }
        int c[3];
        memset(c, 0, sizeof(c));
        FR(j, 3) {
            FR(i, vecs[j].size()) {
                if (find(all(vecs[(j+1)%3]), vecs[j][i]) != vecs[(j+1)%3].end()) {
                    c[j]++;
                }
            }
        }
        cout << c[0] << " " << c[1] << " " << c[2] << endl;
        cout << fill(c[0], c[1], c[2], 0) << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 263 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 263 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 259 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 265 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 254 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 256 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 256 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 257 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 259 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 268 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)