結果

問題 No.1584 Stones around Circle Pond
ユーザー SSRSSSRS
提出日時 2021-07-02 21:54:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,918 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 172,856 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 21:47:19
合計ジャッジ時間 5,318 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 17 ms
4,380 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 15 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 22 ms
4,380 KB
testcase_25 AC 7 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 8 ms
4,376 KB
testcase_28 AC 4 ms
4,384 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 26 ms
4,376 KB
testcase_32 AC 27 ms
4,376 KB
testcase_33 AC 17 ms
4,380 KB
testcase_34 AC 10 ms
4,376 KB
testcase_35 AC 18 ms
4,376 KB
testcase_36 AC 15 ms
4,376 KB
testcase_37 AC 6 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 3 ms
4,380 KB
testcase_47 WA -
testcase_48 AC 8 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 4 ms
4,376 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 9 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
int main(){
  int N, L;
  cin >> N >> L;
  vector<int> d(N);
  for (int i = 0; i < N; i++){
    cin >> d[i];
  }
  vector<int> B(N * 2);
  for (int i = 0; i < N * 2; i++){
    cin >> B[i];
  }
  vector<int> p(N * 2);
  for (int i = 0; i < N; i++){
    p[i] = d[i];
    p[N + i] = L + d[i];
  }
  vector<vector<long long>> s(N * 2, vector<long long>(N * 2, 0));
  for (int i = 0; i < N * 2; i++){
    for (int j = 0; j < N * 2; j++){
      s[i][j] = min(abs(p[j] - p[i]), L * 2 - abs(p[j] - p[i]));
    }
  }
  vector<vector<long long>> A(N * 2, vector<long long>(N * 2 + 1, 0));
  for (int i = 0; i < N * 2; i++){
    for (int j = 0; j < N * 2; j++){
      A[i][j] = s[i][j];
    }
    A[i][N * 2] = B[i];
  }
  for (int i = 0; i < N * 2; i++){
    int pv = i;
    for (int j = i; j < N * 2; j++){
      if (A[j][i] > 0){
        pv = j;
      }
    }
    swap(A[i], A[pv]);
    long long b = modinv(A[i][i]);
    for (int j = N * 2; j >= i; j--){
      A[i][j] *= b;
      A[i][j] %= MOD;
    }
    for (int j = 0; j < N * 2; j++){
      if (i != j){
        for (int k = 0; k <= N * 2; k++){
          if (k != i){
            A[j][k] += MOD - A[j][i] * A[i][k] % MOD;
            A[j][k] %= MOD;
          }
        }
        A[j][i] = 0;
      }
    }
  }
  vector<long long> C(N * 2, 0);
  for (int i = 0; i < N * 2; i++){
    for (int j = 0; j < N * 2; j++){
      C[j] += A[i][N * 2] * s[i][j];
    }
  }
  bool ok = true;
  for (int i = 0; i < N * 2; i++){
    if (B[i] != C[i]){
      ok = false;
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
0