結果
問題 | No.1365 [Cherry 1st Tune] Whose Fault? |
ユーザー | iaNTU |
提出日時 | 2021-01-17 04:01:39 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 324 ms / 2,000 ms |
コード長 | 4,460 bytes |
コンパイル時間 | 2,814 ms |
コンパイル使用メモリ | 199,448 KB |
実行使用メモリ | 11,340 KB |
最終ジャッジ日時 | 2023-08-28 11:17:40 |
合計ジャッジ時間 | 25,129 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
9,780 KB |
testcase_01 | AC | 3 ms
9,608 KB |
testcase_02 | AC | 3 ms
9,600 KB |
testcase_03 | AC | 3 ms
9,848 KB |
testcase_04 | AC | 3 ms
9,692 KB |
testcase_05 | AC | 3 ms
9,648 KB |
testcase_06 | AC | 3 ms
9,788 KB |
testcase_07 | AC | 4 ms
9,812 KB |
testcase_08 | AC | 3 ms
9,684 KB |
testcase_09 | AC | 3 ms
9,692 KB |
testcase_10 | AC | 3 ms
9,596 KB |
testcase_11 | AC | 3 ms
9,600 KB |
testcase_12 | AC | 3 ms
9,588 KB |
testcase_13 | AC | 30 ms
9,784 KB |
testcase_14 | AC | 20 ms
9,824 KB |
testcase_15 | AC | 6 ms
9,908 KB |
testcase_16 | AC | 4 ms
9,960 KB |
testcase_17 | AC | 18 ms
10,000 KB |
testcase_18 | AC | 10 ms
9,936 KB |
testcase_19 | AC | 28 ms
10,040 KB |
testcase_20 | AC | 16 ms
9,780 KB |
testcase_21 | AC | 26 ms
9,904 KB |
testcase_22 | AC | 22 ms
9,792 KB |
testcase_23 | AC | 56 ms
10,672 KB |
testcase_24 | AC | 124 ms
11,072 KB |
testcase_25 | AC | 260 ms
10,908 KB |
testcase_26 | AC | 175 ms
11,000 KB |
testcase_27 | AC | 218 ms
10,352 KB |
testcase_28 | AC | 89 ms
10,024 KB |
testcase_29 | AC | 73 ms
10,176 KB |
testcase_30 | AC | 324 ms
11,108 KB |
testcase_31 | AC | 284 ms
11,176 KB |
testcase_32 | AC | 153 ms
11,048 KB |
testcase_33 | AC | 262 ms
10,556 KB |
testcase_34 | AC | 198 ms
10,676 KB |
testcase_35 | AC | 111 ms
11,096 KB |
testcase_36 | AC | 232 ms
11,312 KB |
testcase_37 | AC | 49 ms
10,168 KB |
testcase_38 | AC | 57 ms
11,132 KB |
testcase_39 | AC | 303 ms
10,868 KB |
testcase_40 | AC | 297 ms
10,840 KB |
testcase_41 | AC | 224 ms
11,008 KB |
testcase_42 | AC | 206 ms
10,208 KB |
testcase_43 | AC | 3 ms
9,692 KB |
testcase_44 | AC | 50 ms
11,340 KB |
testcase_45 | AC | 86 ms
9,784 KB |
ソースコード
// Exported by Exporter.exe // Included from A.cpp // Compile flags -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -fmax-errors=2 #include <bits/stdc++.h> using namespace std; #define PB push_back #define F first #define S second #define MP make_pair #define MTP make_tuple typedef long long int ll; constexpr int kN = int(2E5 + 10); // constexpr int kMod = 998244353; // constexpr int kInf = 0x3f3f3f3f // constexpr ll kInf = 0x3f3f3f3f3f3f3f3f; template <typename T> T ABS(T n) {return n >= 0 ? n : -n;} // Included from C:\Users\ianli\Desktop\CP\template\Various\Fast_IO.cpp static inline char Get_Raw_Char() { static char buf[1 << 16], *p = buf, *end = buf; if (p == end) { if ((end = buf + fread(buf, 1, 1 << 16, stdin)) == buf) return '\0'; p = buf; } return *p++; } static inline int Get_Digit() { char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); return int(c - '0'); } static inline int Get_PInt() { char c = Get_Raw_Char(); int ret; while (!isdigit(c)) c = Get_Raw_Char(); ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); return ret; } static inline int Get_Int() { char c = Get_Raw_Char(); bool neg = false; int ret; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); if (neg) return -ret; return ret; } static inline long long int Get_ll() { char c = Get_Raw_Char(); bool neg = false; long long int ret; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); if (neg) return -ret; return ret; } static inline long long int Get_Pll() { char c = Get_Raw_Char(); long long int ret; while (!isdigit(c)) c = Get_Raw_Char(); ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); return ret; } template <typename T> static inline void Read_P(T &n) { static_assert(is_integral<T>::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); return ; } template <typename T> static inline void Read(T &n) { static_assert(is_integral<T>::value); char c = Get_Raw_Char(); bool neg = false; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); if (neg) n = -n; return ; } template <typename T> static inline void Read_Digit(T &n) { static_assert(is_integral<T>::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); return ; } template <typename T, typename... Targs> static inline void Read(T &n, Targs&... Fargs) { Read(n); return Read(Fargs...); } template <typename T, typename... Targs> static inline void Read_Digit(T &n, Targs&... Fargs) { Read_Digit(n); return Read_Digit(Fargs...); } template <typename T, typename... Targs> static inline void Read_P(T &n, Targs&... Fargs) { Read_P(n); return Read_P(Fargs...); } // End of C:\Users\ianli\Desktop\CP\template\Various\Fast_IO.cpp int f[kN], a[kN], b[kN], p[kN], x[kN], y[kN]; ll sa[kN], sb[kN]; double ans, srp[kN]; double Cal(int n) { ll sd = ABS(sa[n] - sb[n]); return sd * sd / srp[n]; } int Find(int n) {return n == f[n] ? n : f[n] = Find(f[n]);} void Merge(int l, int r) { l = Find(l), r = Find(r); if (l != r) { ans -= Cal(l); ans -= Cal(r); f[r] = l; sa[l] += sa[r]; sb[l] += sb[r]; srp[l] += srp[r]; ans += Cal(l); } } int main() { //ios::sync_with_stdio(false); //cin.tie(0); //freopen("file_name", "r", stdin); //freopen("file_name", "w", stdout); //fstream input, output; //input.open("file_name", ios::in); //output.open("file_name", ios::out); int n, q; Read_P(n); for (int i = 1; i <= n; i++) Read_P(a[i]); for (int i = 1; i <= n; i++) Read_P(b[i]); for (int i = 1; i <= n; i++) Read_P(p[i]); Read_P(q); for (int i = 1; i <= q; i++) Read_P(x[i], y[i]); for (int i = 1; i <= n; i++) sa[i] = a[i]; for (int i = 1; i <= n; i++) sb[i] = b[i]; for (int i = 1; i <= n; i++) srp[i] = 1.0 / p[i]; for (int i = 1; i <= n; i++) f[i] = i; for (int i = 1; i <= n; i++) ans += Cal(i); for (int i = 1; i <= q; i++) { Merge(x[i], y[i]); printf("%.20lf\n", ans); } //input.close(); //output.close(); } // End of A.cpp