Submission #60364
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #include <iostream> #include <ios> #include <iomanip> #include <vector> #include <algorithm> #include <math.h> using namespace std; template < typename T > struct BinaryIndexedTree { vector< T > data; BinaryIndexedTree( int sz) { data.assign(++sz, 0); } T sum( int k) { T ret = 0; for (++k; k > 0; k -= k & -k) ret += data[k]; return (ret); } void add( int k, T x) { for (++k; k < data.size(); k += k & -k) data[k] += x; } }; signed main() { cin.tie(nullptr); ios_base::sync_with_stdio( false ); int T; cin >> T; vector<tuple< int , int , int > > query; vector< double > res(T); for ( int i = 0; i < T; ++i){ int L, K; cin >> L >> K; query.emplace_back(L, K, i); } sort(query.begin(), query.end()); vector< int > dist, cnv(1000 * 1000 * 2 + 1); for ( int i = 0; i <= 1000; ++i){ for ( int j = 0; j <= 1000; ++j){ dist.emplace_back(i * i + j * j); } } sort(dist.begin(), dist.end()); dist.erase(unique(dist.begin(), dist.end()), dist.end()); int d_size = dist.size(); for ( int i = 0; i < d_size; ++i){ cnv[dist[i]] = i; } BinaryIndexedTree< int > bit(d_size); int now_L = 0; for (auto&& [L, K, query_num] : query){ while (now_L <= L){ for ( int i = 0; i < now_L; ++i){ bit.add(cnv[now_L * now_L + i * i], 2); } bit.add(cnv[now_L * now_L * 2], 1); ++now_L; } int ng = -1, ok = d_size; while (ok - ng > 1){ int mid = (ok + ng) / 2; if (bit.sum(mid) >= K){ ok = mid; } else { ng = mid; } } res[query_num] = sqrt (dist[ok]); } for (auto&& e : res){ cout << fixed << setprecision(6) << e << '\n' ; } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 1353 - Function of Euclidean Distance |
ユーザー名 | ei1903 |
投稿日時 | 2020-07-03 21:56:56 |
言語 | C++17 |
状態 | Accepted |
得点 | 400 |
ソースコード長 | 2012 Byte |
最大実行時間 | 193 ms |
最大メモリ使用量 | 25924 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | task01 | 60 / 60 | in01*, sample01.txt |
2 | task02 | 340 / 340 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |
---|---|---|---|---|---|
in01_01.txt | AC | 75 ms | 13516 KB |
1
|
2
|
in01_02.txt | AC | 91 ms | 14240 KB |
1
|
2
|
in01_03.txt | AC | 72 ms | 13564 KB |
1
|
2
|
in01_04.txt | AC | 84 ms | 14164 KB |
1
|
2
|
in01_05.txt | AC | 87 ms | 13352 KB |
1
|
2
|
in01_06.txt | AC | 66 ms | 13568 KB |
1
|
2
|
in01_07.txt | AC | 73 ms | 13400 KB |
1
|
2
|
in01_08.txt | AC | 71 ms | 14388 KB |
1
|
2
|
in01_09.txt | AC | 91 ms | 13452 KB |
1
|
2
|
in01_10.txt | AC | 93 ms | 13800 KB |
1
|
2
|
in02_01.txt | AC | 178 ms | 16572 KB |
2
|
|
in02_02.txt | AC | 182 ms | 17768 KB |
2
|
|
in02_03.txt | AC | 179 ms | 18836 KB |
2
|
|
in02_04.txt | AC | 145 ms | 19908 KB |
2
|
|
in02_05.txt | AC | 121 ms | 20716 KB |
2
|
|
in02_06.txt | AC | 185 ms | 21912 KB |
2
|
|
in02_07.txt | AC | 187 ms | 23240 KB |
2
|
|
in02_08.txt | AC | 184 ms | 23916 KB |
2
|
|
in02_09.txt | AC | 182 ms | 25376 KB |
2
|
|
in02_10.txt | AC | 193 ms | 25924 KB |
2
|
|
sample01.txt | AC | 77 ms | 23920 KB |
1
|
2
|
sample02.txt | AC | 82 ms | 24264 KB |
2
|