QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#364069#90. Fishing GameMax_s_xaM#0 28ms14920kbC++143.6kb2024-03-24 11:15:392024-07-04 03:30:57

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 03:30:57]
  • 评测
  • 测评结果:0
  • 用时:28ms
  • 内存:14920kb
  • [2024-03-24 11:15:39]
  • 提交

answer

#include <iostream>

typedef long long ll;
typedef double lf;

// #define DEBUG 1
struct IO
{
    #define MAXSIZE (1 << 20)
    #define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;
    #if DEBUG
    #else
    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
    #endif
    #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
    #define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')

    template <typename T>
    void Read(T &x)
    {
        #if DEBUG
        std::cin >> x;
        #else
        bool sign = 0; char ch = gc(); x = 0;
        for (; !isdigit(ch); ch = gc())
            if (ch == '-') sign = 1;
        for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
        if (sign) x = -x;
        #endif
    }
    void Read(char *s)
    {
        #if DEBUG
        std::cin >> s;
        #else
        char ch = gc();
        for (; blank(ch); ch = gc());
        for (; !blank(ch); ch = gc()) *s++ = ch;
        *s = 0;
        #endif
    }
    void Read(char &c) {for (c = gc(); blank(c); c = gc());}

    void Push(const char &c)
    {
        #if DEBUG
        putchar(c);
        #else
        if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
        *pp++ = c;
        #endif
    }
    template <typename T>
    void Write(T x)
    {
        if (x < 0) x = -x, Push('-');
        static T sta[35];
        int top = 0;
        do sta[top++] = x % 10, x /= 10; while (x);
        while (top) Push(sta[--top] ^ 48);
    }
    template <typename T>
    void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)

using namespace std;

const int MAXN = 110, mod = 1e9 + 7;

ll f[MAXN][MAXN][MAXN];
int bel[MAXN * 3], cnt[4][4];

int main()
{
    #if DEBUG
    #else
    ios::sync_with_stdio(0), cin.tie(0);
    #endif

    f[0][0][0] = 1;
    for (int t = 1; t <= 300; t++)
    {
        for (int i = 0; i <= t && i <= 100; i++)
            for (int j = 0; i + j <= t && j <= 100; j++)
            {
                if (t - i - j > 100) continue;
                int k = t - i - j;
                if (i >= 2 && j >= 1) f[i][j][k] = (f[i][j][k] + f[i - 1][j - 1][k + 1] * i * (i - 1) * j) % mod;
                if (i >= 2) f[i][j][k] = (f[i][j][k] + f[i - 2][j][k] * i * (i - 1) * (k + 1)) % mod;
                if (i >= 1 && j >= 2) f[i][j][k] = (f[i][j][k] + f[i][j - 2][k] * i * j * (j - 1)) % mod;
                if (i >= 1 && j >= 1 && k >= 1) f[i][j][k] = (f[i][j][k] + f[i - 1][j - 1][k - 1] * i * j * k) % mod;
                if (i >= 1 && k >= 1) f[i][j][k] = (f[i][j][k] + f[i - 1][j + 1][k - 1] * i * k * k) % mod;
                if (j >= 1 && k >= 1) f[i][j][k] = (f[i][j][k] + f[i + 1][j - 1][k - 1] * (j + 1) * j * k) % mod;
                if (k >= 2) f[i][j][k] = (f[i][j][k] + f[i][j][k - 2] * (j + 1) * k * (k - 1)) % mod;
            }
    }

    int n, T;
    Read(n), Read(T);
    while (T--)
    {
        for (int i = 1; i <= 3 * n; i++) bel[i] = 0;
        for (int i = 1; i <= 3; i++)
            for (int j = 1; j <= 3; j++)
                cnt[i][j] = 0;
        for (int i = 1, x; i <= 3; i++)
            for (int j = 1; j <= 2 * n; j++)
            {
                Read(x);
                if (bel[x]) cnt[bel[x]][i]++;
                bel[x] = i;
            }
        cout << f[cnt[1][2] + cnt[2][1]][cnt[2][3] + cnt[3][2]][cnt[1][3] + cnt[3][1]] << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 20ms
memory: 14860kb

input:

2 3
6 1 5 2
1 6 4 2
3 4 5 3
6 3 1 5
2 3 5 6
2 4 4 1
1 2 3 4
3 4 5 6
1 2 5 6

output:

534
534
13896

result:

wrong answer 1st lines differ - expected: '690', found: '534'

Test #2:

score: 0
Wrong Answer
time: 28ms
memory: 14840kb

input:

3 5
9 6 3 8 1 5
4 9 4 2 1 6
5 7 7 3 2 8
4 5 7 5 6 8
2 9 7 1 4 9
3 3 1 6 2 8
7 2 1 3 6 9
8 3 5 4 6 7
4 8 9 5 1 2
8 8 2 5 4 6
1 2 9 3 9 4
6 7 3 5 1 7
1 2 3 4 5 6
4 5 6 7 8 9
1 2 3 7 8 9

output:

654696
13896
397597178
13896
397597178

result:

wrong answer 1st lines differ - expected: '920808', found: '654696'

Test #3:

score: 0
Wrong Answer
time: 27ms
memory: 12728kb

input:

10 5
15 22 9 24 13 11 7 25 21 14 3 5 4 26 19 26 18 29 16 29
16 7 13 30 17 1 4 15 23 9 12 20 22 2 23 18 5 3 10 21
12 30 14 28 27 11 24 8 10 28 17 27 2 20 1 25 6 19 8 6
19 15 27 9 16 21 14 10 19 15 12 11 2 7 16 28 26 25 18 18
12 24 13 29 13 14 1 1 20 29 22 17 3 23 11 28 20 17 5 10
4 24 3 6 4 5 21 22 2...

output:

534531024
539287387
77077890
813456308
219140086

result:

wrong answer 1st lines differ - expected: '169430774', found: '534531024'

Test #4:

score: 0
Wrong Answer
time: 24ms
memory: 14920kb

input:

20 5
26 19 51 35 32 56 13 57 27 9 44 35 34 58 42 12 59 12 8 33 59 16 1 17 11 50 60 28 34 7 33 1 15 8 32 11 29 22 27 52
9 24 15 2 45 19 56 39 28 18 21 3 14 41 6 18 23 25 6 26 23 49 52 17 2 42 10 16 41 31 4 54 43 29 30 46 55 24 49 44
10 21 20 55 20 60 14 4 37 54 45 48 31 5 47 3 5 40 36 36 38 53 7 43 4...

output:

165186072
605394377
857899354
505007928
167371068

result:

wrong answer 1st lines differ - expected: '147852189', found: '165186072'

Test #5:

score: 0
Wrong Answer
time: 24ms
memory: 14856kb

input:

50 10
103 51 39 35 6 66 124 140 131 19 117 97 47 98 14 101 60 41 99 140 94 58 132 30 128 116 44 41 104 7 1 90 75 37 14 95 89 45 116 79 90 86 138 11 7 102 43 87 29 110 127 127 84 26 62 128 107 56 136 47 64 42 124 149 119 71 48 100 40 81 59 11 59 83 62 91 55 4 146 5 73 46 145 117 75 24 20 26 16 97 122...

output:

695654329
819181493
494279050
695661299
308168332
313353776
130518661
498315156
998877104
540026560

result:

wrong answer 1st lines differ - expected: '417911208', found: '695654329'

Test #6:

score: 0
Wrong Answer
time: 23ms
memory: 12888kb

input:

60 10
180 96 39 136 47 63 77 105 74 67 142 122 70 72 137 143 155 95 156 105 121 37 81 3 159 167 139 130 152 180 88 148 149 114 31 43 112 146 127 84 90 75 27 2 46 128 178 116 69 83 117 135 173 177 118 129 34 127 94 40 174 150 56 99 159 116 43 44 59 32 163 175 131 54 113 50 132 50 83 94 149 88 27 161 ...

output:

38353292
471644212
752533693
945133041
596965382
154120918
350955371
734493955
640658914
308525557

result:

wrong answer 1st lines differ - expected: '718107834', found: '38353292'

Test #7:

score: 0
Wrong Answer
time: 27ms
memory: 12732kb

input:

70 10
78 164 105 187 88 118 8 96 82 143 38 127 27 93 18 171 19 158 112 91 179 17 40 15 99 205 113 19 186 16 26 82 4 41 193 5 110 79 201 106 161 59 183 196 123 127 69 37 117 130 88 141 96 93 149 113 176 206 46 195 35 178 102 111 155 41 25 148 150 179 185 61 166 136 118 176 46 50 61 84 124 150 112 185...

output:

561220066
660071062
101141188
674542049
749928148
655500613
721228932
568553285
964009020
933009103

result:

wrong answer 1st lines differ - expected: '574244039', found: '561220066'

Test #8:

score: 0
Wrong Answer
time: 23ms
memory: 12768kb

input:

80 10
125 87 139 196 191 41 58 194 2 175 150 76 18 87 1 40 180 166 13 119 159 123 210 135 61 224 142 149 222 216 197 113 234 194 9 231 96 71 198 176 98 36 24 185 235 157 80 122 226 187 42 240 154 171 25 218 195 198 124 50 113 32 91 119 45 141 53 12 74 121 158 96 180 116 145 22 142 133 88 182 16 124 ...

output:

477647682
848064798
452498892
110131575
591919326
357511593
832017554
218471087
456550410
498375667

result:

wrong answer 1st lines differ - expected: '182989152', found: '477647682'

Test #9:

score: 0
Wrong Answer
time: 27ms
memory: 12800kb

input:

90 10
42 170 5 215 133 153 104 85 9 164 157 42 87 108 64 161 205 168 228 216 257 81 163 68 195 99 234 136 231 142 127 149 86 182 224 219 80 125 7 230 256 41 204 125 251 77 86 29 28 204 55 15 30 35 174 53 269 23 240 127 262 199 260 232 259 46 80 43 49 169 233 88 192 27 217 186 47 185 228 249 63 245 2...

output:

290669530
633519789
369131510
386250061
147205556
705791429
45283727
959577330
887471261
603046343

result:

wrong answer 1st lines differ - expected: '896986561', found: '290669530'

Test #10:

score: 0
Wrong Answer
time: 23ms
memory: 12772kb

input:

99 10
243 69 109 28 151 100 296 2 258 112 25 206 181 148 21 246 12 84 254 250 91 248 46 14 183 162 38 82 130 48 20 150 139 247 283 24 29 93 191 105 129 38 131 87 147 166 22 297 297 71 232 185 106 123 291 15 63 101 286 214 224 29 187 154 215 292 226 223 225 55 23 170 165 238 137 113 203 79 21 217 289...

output:

427474070
680603430
299761072
140954678
535027595
782448129
22234942
51938477
238143681
404047068

result:

wrong answer 1st lines differ - expected: '842856263', found: '427474070'