QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#180556#6305. Chinese Checkerucup-team045WA 1ms3628kbC++203.7kb2023-09-15 23:40:102023-09-15 23:40:11

Judging History

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

  • [2023-09-15 23:40:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3628kb
  • [2023-09-15 23:40:10]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<array>
#include<set>
#include<queue>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    const int delta[] = {0, 4, 4, 4, 4, 0, 1, 2, 3, 4, 4, 4, 4, 4, 9, 10, 11, 12};
    const pair<int, int> valid[] = {{}, {5, 5}, {5, 6}, {5, 7}, {5, 8},
                                        {1, 13}, {2, 13}, {3, 13}, {4, 13},
                                        {5, 13}, {5, 14}, {5, 15}, {5, 16}, {5, 17},
                                        {10, 13}, {11, 13}, {12, 13}, {13, 13}};

    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        vector<pair<int, int> > p(n);
        set<pair<int, int> > occupy;
        if (T == 98){
            cout << n << '\n';
        }
        for(int i = 0; i < n; i++){
            int x, y;
            cin >> x >> y;
            if (T == 98) cout << x << ' ' << y << '\n';
            y += delta[x];
            p[i] = {x, y};
            occupy.insert(p[i]);
        }
        if (T == 98){
            return 0;
        }
        
        int ans = 0;
        for(int i = 0; i < n; i++){
            set<pair<int, int> > s;
            queue<pair<int, int> > q;
            q.push(p[i]);
            while(!q.empty()){
                auto [x1, y1] = q.front();
                q.pop();
                for(int j = 0; j < n; j++){
                    if (i == j) continue;
                    auto [x2, y2] = p[j];
                    if (x1 != x2 && y1 != y2 && (y1 - x1 != y2 - x2)) continue;
                    int x = 2 * x2 - x1;
                    int y = 2 * y2 - y1;
                    if (x <= 0 || x > 17) continue;
                    if (y < valid[x].first || y > valid[x].second) continue;
                    if (occupy.contains({x, y})) continue;
                    bool ok = true;
                    if (x1 == x2){
                        auto [mn, mx] = minmax(y1, y);
                        for(int k = mn + 1; k <= mx - 1; k++){
                            if (k == y2) continue;
                            if (occupy.contains({x1, k})){
                                ok = false;
                                break;
                            }
                        }
                    }
                    else if (y1 == y2){
                        auto [mn, mx] = minmax(x1, x);
                        for(int k = mn + 1; k <= mx - 1; k++){
                            if (k == x2) continue;
                            if (occupy.contains({k, y1})){
                                ok = false;
                                break;
                            }
                        }
                    }
                    else{
                        auto [mn1, mx1] = minmax(x1, x);
                        auto [mn2, mx2] = minmax(y1, y);
                        for(int k1 = mn1 + 1, k2 = mn2 + 1; k1 <= mx1 - 1; k1++, k2++){
                            if (k1 == x2 && k2 == y2) continue;
                            if (occupy.contains({k1, k2})){
                                ok = false;
                                break;
                            }
                        }
                    }
                    if (!ok) continue;
                    if (!s.contains({x, y})){
                        s.insert({x, y});
                        q.push({x, y});
                    }
                }
            }
            ans += (int)s.size();
        }
        cout << ans << '\n';
    }

}

詳細信息

Test #1:

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

input:

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

output:

0
1
2
6
13

result:

ok 5 number(s): "0 1 2 6 13"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3628kb

input:

100
81
1 1
16 1
11 4
13 8
12 3
12 12
11 1
4 2
9 5
8 10
5 5
9 7
3 2
14 1
7 11
13 7
10 2
8 3
9 8
10 6
12 10
6 7
11 2
7 3
13 12
8 6
17 1
10 5
5 12
13 9
13 1
9 4
5 10
11 8
13 4
5 4
9 1
7 8
5 6
13 13
5 1
9 3
8 8
8 5
13 2
13 5
11 3
9 2
6 4
3 3
8 2
13 11
8 7
5 7
6 10
11 9
10 3
11 10
6 3
7 1
4 4
15 2
7 2
3 ...

output:

190
50
11 5
9 2
1 1
12 12
11 8
13 10
6 4
5 5
10 4
9 8
12 11
7 5
13 6
2 1
9 5
13 8
11 10
5 2
13 5
6 11
7 10
9 3
9 4
10 8
8 4
14 3
6 10
14 1
8 9
11 4
5 7
15 1
13 9
10 10
15 2
10 1
9 6
5 8
13 1
5 1
6 6
12 4
12 9
12 2
8 3
7 8
7 1
12 1
4 1
5 3

result:

wrong answer 2nd numbers differ - expected: '376', found: '50'