提出 #36050187
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;
// and so on
string arr[10];
vector<pii> pos;
bool issquare(int a, int b, int c, int d) {
pii p[4] = {pos[a], pos[b], pos[c], pos[d]};
int dist[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
auto [ax, ay] = p[i];
auto [bx, by] = p[j];
dist[i][j] = (ax - bx) * (ax - bx) + (ay - by) * (ay - by);
}
sort(dist[i], dist[i] + 4);
}
int r = dist[0][1];
for (int i = 0; i < 4; i++) {
for (int j = 1; j < 3; j++)
if (dist[i][j] != r) return false;
}
r = dist[0][3];
for (int i = 1; i < 4; i++)
if (r != dist[i][3]) return false;
return true;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
for (int i = 0; i < 10; i++) cin >> arr[i];
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (arr[i][j] == '#') pos.push_back({i, j});
}
}
int ans = 0;
int N = pos.size();
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
for (int k = j + 1; k < N; k++) {
for (int l = k + 1; l < N; l++) {
ans += issquare(i, j, k, l);
}
}
}
}
cout << ans;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Counting Squares |
| ユーザ | jame0313 |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 300 |
| コード長 | 1467 Byte |
| 結果 | AC |
| 実行時間 | 120 ms |
| メモリ | 3580 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_01.txt | AC | 7 ms | 3556 KiB |
| 00_sample_02.txt | AC | 1 ms | 3572 KiB |
| 01_test_01.txt | AC | 2 ms | 3488 KiB |
| 01_test_02.txt | AC | 120 ms | 3512 KiB |
| 01_test_03.txt | AC | 12 ms | 3440 KiB |
| 01_test_04.txt | AC | 5 ms | 3556 KiB |
| 01_test_05.txt | AC | 2 ms | 3504 KiB |
| 01_test_06.txt | AC | 3 ms | 3480 KiB |
| 01_test_07.txt | AC | 10 ms | 3476 KiB |
| 01_test_08.txt | AC | 28 ms | 3580 KiB |
| 01_test_09.txt | AC | 39 ms | 3512 KiB |
| 01_test_10.txt | AC | 56 ms | 3580 KiB |
| 01_test_11.txt | AC | 67 ms | 3436 KiB |
| 01_test_12.txt | AC | 57 ms | 3568 KiB |
| 01_test_13.txt | AC | 48 ms | 3492 KiB |