結果

問題 No.1584 Stones around Circle Pond
ユーザー risujirohrisujiroh
提出日時 2021-07-02 21:49:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 201,836 KB
最終ジャッジ日時 2025-01-22 15:53:42
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 53 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 = row + 1; i < 2 * n; ++i) {
      if (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);
    }
  cout << "Yes\n";
}
0