Submission #1001446
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using D = double; using uint = unsigned int; #ifdef WIN32 #define LLD "%I64d" #else #define LLD "%lld" #endif #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define popcount(x) __builtin_popcount(x) const int maxn = 16; const int maxmask = 1 << 16; const ld inf = 1e18; int x[maxn], y[maxn], a[maxn]; ld ans[maxmask], answer[maxmask]; ld d[maxn][maxn]; ld mindist[maxmask][maxn]; int n; inline ld shedge(int m1, int m2) { ld answer = inf; for (int j = 0; j < n; j++) if (m1 & (1 << j)) answer = min(answer, mindist[m2][j]); return answer; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d%d", &x[i], &y[i], &a[i]); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) d[i][j] = sqrt((ld)(x[i] - x[j]) * (x[i] - x[j]) + (ld)(y[i] - y[j]) * (y[i] - y[j])); } int km = 1 << n; for (int mask = 0; mask < km; mask++) { for (int i = 0; i < n; i++) { mindist[mask][i] = inf; for (int j = 0; j < n; j++) if (mask & (1 << j)) mindist[mask][i] = min(mindist[mask][i], d[i][j]); } } for (int i = 0; i < n; i++) ans[1 << i] = a[i]; for (int mask = 1; mask < km; mask++) if (popcount(mask) > 1) { ans[mask] = -inf; // for (int i = 0; i < n; i++) if (mask & (1 << i)) // { // ld d = mindist[mask ^ (1 << i)][i]; // /*if (a[i] > d || ans[mask ^ (1 << i)] / (popcount(mask) - 1) > d)*/ ans[mask] = max(ans[mask], ans[mask ^ (1 << i)] + a[i] - d); // } for (int submask = (mask & (mask - 1)); submask > 0; submask = ((submask - 1) & mask)) { ld d = shedge(submask, mask ^ submask); ans[mask] = max(ans[mask], ans[submask] + ans[mask ^ submask] - d); } // cout << mask << ' ' << ans[mask] << endl; } // cout.precision(20); // cout << ans[km - 1] / n << endl; for (int i = 0; i < n; i++) answer[1 << i] = a[i]; for (int mask = 1; mask < km; mask++) if (popcount(mask) > 1) { answer[mask] = ans[mask] / popcount(mask); for (int submask = (mask & (mask - 1)); submask > 0; submask = ((submask - 1) & mask)) { answer[mask] = max(answer[mask], min(answer[submask], answer[mask ^ submask])); } } cout.precision(20); cout << answer[km - 1] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Water Distribution |
User | KAN |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 2660 Byte |
Status | AC |
Exec Time | 1054 ms |
Memory | 9472 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:43:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:46:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d%d", &x[i], &y[i], &a[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 1043 ms | 9472 KB |
001.txt | AC | 1041 ms | 9472 KB |
002.txt | AC | 1039 ms | 9472 KB |
003.txt | AC | 1042 ms | 9472 KB |
004.txt | AC | 1048 ms | 9472 KB |
005.txt | AC | 1037 ms | 9472 KB |
006.txt | AC | 1045 ms | 9472 KB |
007.txt | AC | 1041 ms | 9472 KB |
008.txt | AC | 1050 ms | 9472 KB |
009.txt | AC | 1045 ms | 9472 KB |
010.txt | AC | 1046 ms | 9472 KB |
011.txt | AC | 1046 ms | 9472 KB |
012.txt | AC | 1047 ms | 9472 KB |
013.txt | AC | 1039 ms | 9472 KB |
014.txt | AC | 1051 ms | 9472 KB |
015.txt | AC | 1054 ms | 9472 KB |
016.txt | AC | 1036 ms | 9472 KB |
017.txt | AC | 1046 ms | 9472 KB |
018.txt | AC | 1049 ms | 9472 KB |
019.txt | AC | 1040 ms | 9472 KB |
020.txt | AC | 1021 ms | 9472 KB |
021.txt | AC | 1034 ms | 9472 KB |
022.txt | AC | 1035 ms | 9472 KB |
023.txt | AC | 1026 ms | 9472 KB |
024.txt | AC | 1023 ms | 9472 KB |
025.txt | AC | 1020 ms | 9472 KB |
026.txt | AC | 1026 ms | 9472 KB |
027.txt | AC | 1031 ms | 9472 KB |
028.txt | AC | 1023 ms | 9472 KB |
029.txt | AC | 1022 ms | 9472 KB |
030.txt | AC | 1019 ms | 9472 KB |
031.txt | AC | 1023 ms | 9472 KB |
032.txt | AC | 1017 ms | 9472 KB |
033.txt | AC | 1018 ms | 9472 KB |
034.txt | AC | 1015 ms | 9472 KB |
035.txt | AC | 1016 ms | 9472 KB |
036.txt | AC | 1014 ms | 9472 KB |
037.txt | AC | 1014 ms | 9472 KB |
038.txt | AC | 1015 ms | 9472 KB |
039.txt | AC | 1016 ms | 9472 KB |
040.txt | AC | 3 ms | 256 KB |
041.txt | AC | 3 ms | 256 KB |
042.txt | AC | 3 ms | 256 KB |
043.txt | AC | 3 ms | 384 KB |
example0.txt | AC | 3 ms | 256 KB |
example1.txt | AC | 1031 ms | 9472 KB |