QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#180553 | #6305. Chinese Checker | ucup-team045 | WA | 17ms | 3656kb | C++20 | 3.5kb | 2023-09-15 23:23:28 | 2023-09-15 23:23:28 |
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, 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';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
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: 17ms
memory: 3656kb
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 368 205 489 370 213 151 39 328 87 1 129 103 64 25 137 390 294 10 214 82 188 261 16 102 236 298 439 172 80 211 281 25 7 104 179 418 282 51 163 260 47 10 149 79 181 30 145 328 122 190 279 0 105 114 53 22 5 59 159 167 26 444 163 209 4 52 0 251 109 100 395 0 346 75 105 73 353 61 28 471 352 6 187 89 ...
result:
wrong answer 2nd numbers differ - expected: '376', found: '368'