結果
| 問題 |
No.1584 Stones around Circle Pond
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2021-07-02 22:03:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,546 bytes |
| コンパイル時間 | 2,304 ms |
| コンパイル使用メモリ | 200,756 KB |
| 最終ジャッジ日時 | 2025-01-22 16:01:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 32 |
ソースコード
#include <bits/stdc++.h>
int main() {
using namespace std;
cin.tie(nullptr)->sync_with_stdio(false);
int n, l;
cin >> n >> l;
vector<int> d(n);
for (auto&& e : d) cin >> e;
vector a(2 * n, vector<int64_t>(2 * n + 1));
for (int i = 0; i < 2 * n; ++i)
for (int j = 0; j < 2 * n; ++j)
if (i < n and j < n)
a[i][j] = abs(d[i] - d[j]);
else if (i < n)
a[i][j] = l - a[i][j - n];
else if (j < n)
a[i][j] = l - a[i - n][j];
else
a[i][j] = a[i - n][j - n];
for (int i = 0; i < 2 * n; ++i) cin >> a[i][2 * n];
int row = 0;
for (int col = 0; col < 2 * n; ++col) {
for (int i = row + 1; i < 2 * n; ++i)
if (a[i][col]) {
swap(a[row], a[i]);
break;
}
if (a[row][col] == 0) continue;
{
auto g = accumulate(begin(a[row]), end(a[row]), 0, [](auto x, auto y) { return gcd(x, y); });
for (auto&& e : a[row]) e /= g;
}
for (int i = 0; i < 2 * n; ++i) {
if (i == row or a[i][col] == 0) continue;
auto g = gcd(a[row][col], a[i][col]);
auto x = a[row][col] / g;
auto y = a[i][col] / g;
for (int j = col; j <= 2 * n; ++j) a[i][j] = a[i][j] * x - a[row][j] * y;
}
++row;
}
for (int i = row; i < 2 * n; ++i)
if (a[i][2 * n]) {
cout << "No\n";
exit(0);
}
for (int i = 0; i < row; ++i)
if (a[i][2 * n] % a[i][i] or a[i][2 * n] / a[i][i] < 0) {
cout << "No\n";
exit(0);
}
cout << "Yes\n";
}
risujiroh