QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#180545 | #6305. Chinese Checker | ucup-team045 | WA | 23ms | 3596kb | C++20 | 3.3kb | 2023-09-15 23:08:43 | 2023-09-15 23:08:43 |
Judging History
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;
for(int i = 0; i < n; i++){
int x, y;
cin >> x >> y;
y += delta[x];
p[i] = {x, y};
occupy.insert(p[i]);
}
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, y2);
for(int k = mn + 1; k <= mx - 1; k++){
if (occupy.contains({x1, k})){
ok = false;
break;
}
}
}
else if (y1 == y2){
auto [mn, mx] = minmax(x1, x2);
for(int k = mn + 1; k <= mx - 1; k++){
if (occupy.contains({k, y1})){
ok = false;
break;
}
}
}
else{
auto [mn1, mx1] = minmax(x1, x2);
auto [mn2, mx2] = minmax(y1, y2);
for(int k1 = mn1 + 1, k2 = mn2 + 1; k1 <= mx1 - 1; k1++, k2++){
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';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 23ms
memory: 3596kb
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:
353 624 332 717 619 390 201 45 508 93 1 356 117 127 25 201 589 478 10 272 184 241 630 16 112 463 479 668 305 89 301 457 25 10 153 257 590 398 53 317 559 50 10 333 80 287 33 242 572 137 295 474 0 120 130 88 22 5 99 229 218 26 607 230 321 4 68 0 413 144 148 506 0 562 100 112 90 457 79 34 742 644 7 325...
result:
wrong answer 1st numbers differ - expected: '190', found: '353'