Submission #60360
ソースコード
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 97 98 99 100 | #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <ios> #include <iomanip> using namespace std; template < typename T > struct BinaryIndexedTree { vector< T > data; BinaryIndexedTree() = default ; explicit BinaryIndexedTree( size_t sz) : data(sz + 1, 0) {} explicit BinaryIndexedTree( const vector< T > &vs) : data(vs.size() + 1, 0) { for ( size_t i = 0; i < vs.size(); i++) data[i + 1] = vs[i]; for ( size_t i = 1; i < data.size(); i++) { size_t j = i + (i & -i); if (j < data.size()) data[j] += data[i]; } } void add( int k, const T &x) { for (++k; k < ( int ) data.size(); k += k & -k) data[k] += x; } T query( int k) const { T ret = T(); for (++k; k > 0; k -= k & -k) ret += data[k]; return ret; } int lower_bound(T x) const { int i = 0; for ( int k = 1 << (__lg(data.size() - 1) + 1); k > 0; k >>= 1) { if (i + k < data.size() && data[i + k] < x) { x -= data[i + k]; i += k; } } return i; } int upper_bound(T x) const { int i = 0; for ( int k = 1 << (__lg(data.size() - 1) + 1); k > 0; k >>= 1) { if (i + k < data.size() && data[i + k] <= x) { x -= data[i + k]; i += k; } } return i; } }; 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()); BinaryIndexedTree< int > bit(1000 * 1000 * 2 + 1); 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(now_L * now_L + i * i, 2); } bit.add(now_L * now_L * 2, 1); ++now_L; } res[query_num] = sqrt (bit.lower_bound(K)); } for (auto&& e : res){ cout << fixed << setprecision(5) << e << '\n' ; } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 1353 - Function of Euclidean Distance |
ユーザー名 | ei1903 |
投稿日時 | 2020-07-03 21:54:00 |
言語 | C++17 |
状態 | Accepted |
得点 | 400 |
ソースコード長 | 2336 Byte |
最大実行時間 | 123 ms |
最大メモリ使用量 | 19960 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | task01 | 60 / 60 | in01*, sample01.txt |
2 | task02 | 340 / 340 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |
---|---|---|---|---|---|
in01_01.txt | AC | 31 ms | 8412 KB |
1
|
2
|
in01_02.txt | AC | 35 ms | 8364 KB |
1
|
2
|
in01_03.txt | AC | 22 ms | 8312 KB |
1
|
2
|
in01_04.txt | AC | 32 ms | 8264 KB |
1
|
2
|
in01_05.txt | AC | 39 ms | 8340 KB |
1
|
2
|
in01_06.txt | AC | 25 ms | 8416 KB |
1
|
2
|
in01_07.txt | AC | 24 ms | 8368 KB |
1
|
2
|
in01_08.txt | AC | 21 ms | 8316 KB |
1
|
2
|
in01_09.txt | AC | 40 ms | 8260 KB |
1
|
2
|
in01_10.txt | AC | 28 ms | 8336 KB |
1
|
2
|
in02_01.txt | AC | 114 ms | 11468 KB |
2
|
|
in02_02.txt | AC | 111 ms | 12512 KB |
2
|
|
in02_03.txt | AC | 115 ms | 13556 KB |
2
|
|
in02_04.txt | AC | 74 ms | 14348 KB |
2
|
|
in02_05.txt | AC | 68 ms | 15132 KB |
2
|
|
in02_06.txt | AC | 119 ms | 16172 KB |
2
|
|
in02_07.txt | AC | 123 ms | 17084 KB |
2
|
|
in02_08.txt | AC | 113 ms | 18004 KB |
2
|
|
in02_09.txt | AC | 118 ms | 19044 KB |
2
|
|
in02_10.txt | AC | 119 ms | 19960 KB |
2
|
|
sample01.txt | AC | 24 ms | 17948 KB |
1
|
2
|
sample02.txt | AC | 28 ms | 17888 KB |
2
|