QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695035#6425. Harmonious Rectanglesadbo1WA 2ms3652kbC++201.4kb2024-10-31 19:11:172024-10-31 19:11:19

Judging History

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

  • [2024-10-31 19:11:19]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3652kb
  • [2024-10-31 19:11:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL
#include "C:\Program Files\DEBUG\debug.h"
#else
#define debug(...) 114514
#define ps 114514
#endif

const int mod = 1e9 + 7;

int power(int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

map<pair<int, int>, int> mp;
vector<int> res = {
    15,        339,       4761,    52929,     517761,    4767849,
    339,       16485,     518265,  14321907,  387406809, 460338013,
    429534507, 597431612, 4761,    518265,    43022385,  486780060,
    429534507, 792294829, 52929,   14321907,  486780060, 288599194,
    130653412, 748778899, 517761,  387406809, 429534507, 130653412,
    246336683, 579440654, 4767849, 460338013, 792294829, 748778899,
};
void solve() {
    int n, m;
    cin >> n >> m;

    if (n == 1 || m == 1) {
        cout << 0 << '\n';
        return;
    }
    if (n > 7 || m > 7) {
        cout << power(3, n * m) << '\n';
        return;
    }
    cout << res[mp[{n, m}]] << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int t = 1;
    int tot = 0;
    for (int i = 2; i <= 7; i++) {
        for (int j = 2; j <= 7; j++) {
            mp[{i, j}] = tot++;
        }
    }
    cin >> t;
    while (t--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

input:

3
1 4
2 2
3 3

output:

0
15
16485

result:

ok 3 number(s): "0 15 16485"

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3508kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
339
4761
52929
517761
4767849
43046721
387420489
486784380
381059392
429534507
865810542
792294...

result:

wrong answer 302nd numbers differ - expected: '4761', found: '429534507'