QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386004#4345. hpmo / 赫露艾斯塔alpha102220 ✓23ms10132kbC++141.1kb2024-04-11 10:56:162024-04-11 10:56:16

Judging History

你现在查看的是测评时间为 2024-04-11 10:56:16 的历史记录

  • [2024-04-15 20:59:01]
  • 管理员手动重测该提交记录
  • 测评结果:100
  • 用时:459ms
  • 内存:14440kb
  • [2024-04-11 10:56:16]
  • 评测
  • 测评结果:20
  • 用时:23ms
  • 内存:10132kb
  • [2024-04-11 10:56:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 1e5;
const int M = 2e5;
const int B = 250;

int n, m;
int x[N + 5], y[N + 5];
int a[M + 5], b[M + 5], c[M + 5];
double dist(int i, int j) { return fabs((ll)a[j] * x[i] + (ll)b[j] * y[i] + c[j]) / sqrt((ll)a[j] * a[j] + (ll)b[j] * b[j]); }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool vis[N + 5];
vector<int> key;
vector<pair<double, int>> line[N + 5];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d%d", x + i, y + i);
  for (int i = 1; i <= m; ++i) scanf("%d%d%d", a + i, b + i, c + i);
  for (int i = 1; i <= min(B, n); ++i) {
    int j;
    do j = uniform_int_distribution<int>(1, n)(rng); while (vis[j]);
    vis[j] = 1, key.push_back(j);
  }
  for (int i = 1; i <= m; ++i) {
    int res = 0;
    for (int j : key)
      if (!res || dist(j, i) < dist(res, i)) res = j;
    line[res].emplace_back(atan2(-a[i], b[i]), i);
  }
  for (int i : key) {
    sort(line[i].begin(), line[i].end());
    for (auto [_, j] : line[i]) printf("%d\n", j);
  }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 19ms
memory: 9564kb

input:

9997 9990
9019266 5863617
-9132512 9933564
-3874637 4993765
444830 -2250447
-2352800 3441144
-6132076 -4919200
-1607690 1649753
-3707230 -9677822
-4044043 949637
-7761530 2069488
9475384 4537713
-6619947 -121926
5929373 653750
5738540 -7373755
1630427 2169595
7049000 185616
-4436632 7644104
-7326158...

output:

707
5676
428
5884
5363
5967
8887
6101
7139
7970
2881
7032
5262
3575
8287
7294
3743
875
9261
6488
9293
1285
2744
4841
5360
5738
7107
7907
3595
4432
7039
8603
1927
4209
9106
3512
1294
4946
7127
5015
850
7298
4565
5101
3105
5345
3971
1164
1140
2879
8736
7018
5494
4135
5019
6668
7054
5589
4065
3568
3984...

result:

ok cost = 5665879

Test #2:

score: 0
Accepted
time: 23ms
memory: 8572kb

input:

10000 10000
-9867885 -6351277
3489722 8586294
-813430 9340951
2086219 9210082
8903276 -6786767
8717742 1297662
8333166 -3317203
7936341 4929952
4912513 9933563
-4537308 -9543067
7319834 8626975
-5937113 -4470138
3427489 -6194898
-7290157 -3404718
-3724079 2294733
7598186 6969998
-9934248 6924016
428...

output:

6192
8618
9992
6832
231
7803
6018
6360
181
3272
6286
2954
5221
1207
497
627
6814
8543
6931
3900
8535
788
5781
1050
3016
3907
6141
8505
9415
9851
807
1299
1465
2801
2829
2997
3605
4374
4559
4894
5021
5412
7451
9670
858
5933
3065
3582
4768
5635
6079
6940
9040
9093
1180
8665
5987
8859
906
9241
4295
940...

result:

ok cost = 5576801

Test #3:

score: 0
Accepted
time: 23ms
memory: 9588kb

input:

10000 10000
-660951 65490
-29833 2757177
-340846 10961
-7150119 33459
5136755 4278
25550 775750
5201020 -5199
75169 4666130
67597 1714309
-36541 -3114964
-4240048 31425
73017 2383801
-94770 -836461
7728250 65154
-62043 -9108010
49090 4597522
-6217034 -71671
-6369695 31577
31865 8971451
72473 9040891...

output:

4082
7425
2442
3452
8240
7035
2988
2523
3435
4362
8131
9020
3175
1970
4309
3552
7264
8874
916
7895
6682
1337
4520
5040
313
899
7118
7923
7644
9950
3940
4195
6047
8167
4710
1677
7305
9910
4334
1842
9923
746
9996
1064
5387
8869
4469
5351
4438
9574
1051
1440
8719
9313
3149
8064
5665
6610
6767
5178
7802...

result:

ok cost = 5389247

Test #4:

score: 0
Accepted
time: 23ms
memory: 8640kb

input:

9998 9990
7582 3856200
9459 4381
-5500354 -8064
3998 -8251368
3506 6715096
-8509 -321964
1725 -1322233
5849831 -1846
-5027 1011243
2596 1990975
-9353 -1004281
3956 -604279
8402459 6848
5419 -2187141
8567983 -2494
1683 4015848
-7337 8293412
-7173 7399645
3799 8763972
4228499 -1835
-8493 -2845008
-833...

output:

7429
918
9808
6404
2044
558
4686
330
705
440
4919
4151
7532
6815
1592
6435
8448
2070
8362
605
5249
5349
5937
1033
5524
9212
9671
8397
8981
265
4083
9648
6801
754
5682
8451
3540
6559
662
6494
333
652
274
708
2736
9682
8612
9919
289
5138
8216
2647
7539
4824
1807
2653
9153
7741
3120
3211
5879
7309
7685...

result:

ok cost = 5347401

Test #5:

score: 0
Accepted
time: 23ms
memory: 8276kb

input:

10000 10000
-9144786 9458431
9233721 -9868159
-9349753 -9965861
9814616 9358465
9750984 -9543095
-9665224 9051130
9964223 9790510
-9960351 9771782
9534798 9181687
-9569872 -9172559
9221230 -9786591
9879500 9613336
9830155 9270397
-9866671 -9417021
9337577 9481408
9668674 -9921731
-9817467 9225012
99...

output:

6879
7638
3731
4376
1906
5842
1281
1953
5339
2611
4188
2671
3022
2680
4836
5476
2309
4942
8442
1487
3632
5161
188
4627
6329
1970
982
271
477
2494
4115
1034
4630
1061
5861
58
17
9511
811
5653
7270
7761
2341
1867
512
9219
2105
6383
5156
4886
5552
3240
4588
4181
6215
5253
7907
1308
5678
8309
4215
7344
...

result:

ok cost = 4977971

Test #6:

score: 0
Accepted
time: 23ms
memory: 8904kb

input:

9990 9990
-967949 32827
-1626409 25231
3914913 -17371
-3340636 -33022
-5664776 7967173
-5125 -27879
4988706 -3540854
-9980324 -14749
2914084 -16185
-3231561 9522
1044674 19300
-3619589 16689
1056583 4919512
-141677 -29040
-2587777 -8824
8185554 -10101
-3482427 -1834
8972857 -3639730
-7063435 -8995
2...

output:

9516
7145
3903
613
6837
715
8700
1296
4977
3351
7054
7432
9047
6705
3386
3686
3984
2163
8024
1236
931
5991
8618
5537
9961
2870
9244
876
124
1268
9447
8760
8374
9579
4596
4044
5011
4375
343
6181
6731
5644
4909
2452
5773
8426
1259
999
6884
1774
4016
9857
7817
1359
6178
8157
8544
3420
9556
8581
3939
42...

result:

ok cost = 5016372

Test #7:

score: 0
Accepted
time: 23ms
memory: 10132kb

input:

10000 10000
1968477 4944613
6286972 -9851737
-6437502 -4770833
1151523 -7901737
-3149643 9687929
-2205837 -376397
-1324393 5174345
3034439 6480824
-9341786 -7611299
8694184 -3435575
95532 -7378553
-428305 -2628108
263 -5693153
4995174 -4874425
-5093158 -5437311
5434124 6700984
-984539 2903531
293896...

output:

6611
3367
5463
1617
2853
2948
4444
5016
5461
6155
8112
399
972
7016
8235
3847
7487
2718
3044
7713
1057
1315
3116
4187
4403
5655
7583
8434
8830
9756
464
8901
9707
1091
2600
3725
4557
4661
4982
7593
8184
8200
8846
9711
5483
7078
5060
1950
6033
1866
1980
3228
3646
4376
8968
2100
5729
5856
5861
8831
863...

result:

ok cost = 2320702

Test #8:

score: 0
Accepted
time: 23ms
memory: 9388kb

input:

10000 10000
-1326300 -7573500
7443150 -8520425
9706112 5114022
-2518500 -7674600
5016700 630200
9734400 8710400
3048966 -5268394
610442 -1407578
7055300 -101500
616523 3597946
-3141466 6983439
5742991 8144648
5661864 4435109
-2226200 -4249300
-5924600 -9402400
6799900 -3953000
6648000 -8833700
80689...

output:

4774
4448
1449
6367
6948
9506
6915
5091
4752
6715
1314
2772
8178
7393
8121
7021
2842
8743
176
7731
2928
5536
1156
710
7622
8817
509
9226
293
3216
7948
5849
1774
4445
6213
9313
23
7624
3807
7572
2824
7317
2756
8741
4509
873
1625
2768
3604
6235
9080
9050
9594
7342
7766
4745
6240
1670
8696
2858
6491
12...

result:

ok cost = 5659088

Test #9:

score: 0
Accepted
time: 23ms
memory: 8824kb

input:

10000 10000
-2318095 2019446
-4035918 2985975
713901 -223858
3296173 -824906
-83732 1397407
-316288 128177
-1184337 -2715514
18449 -3918764
482679 -859441
2741883 -4078535
-5781803 1089808
-2596705 -3341805
-3283602 4287650
-204221 2840836
-1521345 -11681
5377933 4075120
-862909 -1012305
-616438 -64...

output:

1668
1756
4434
7503
1248
2444
13
2702
7835
4247
8722
810
6760
6385
723
7658
4409
5361
7355
452
2923
1364
754
2034
2169
6689
4988
4371
8931
494
8121
222
3122
2649
4704
9547
1046
2293
6565
8340
9518
5633
1373
8420
7357
1469
974
3577
8947
5659
9313
9216
7184
4841
756
5802
2059
7903
8349
9294
6332
5284
...

result:

ok cost = 5553635

Test #10:

score: 0
Accepted
time: 19ms
memory: 9592kb

input:

10000 10000
30399 911905
6099694 -822955
-1970492 1924582
8133655 -2339409
1225483 -1771551
-578009 -1208298
-5626070 5251285
-3033849 -8699056
5626898 3642052
-2037392 -1207307
-6932083 -3926601
7017312 -2624958
-4505258 -3199363
3196125 4153290
5919593 3128640
-5235780 -3147933
-4493757 162244
573...

output:

130
4909
3517
9257
7385
4251
2904
7762
4058
1007
3277
6928
8961
3872
110
4382
2123
8177
8374
9337
2697
1557
2324
8960
6391
4033
5972
5098
5149
8517
7275
4521
2360
2650
81
3740
2879
9564
6117
1187
8606
7289
9096
701
2901
7035
9957
3360
6141
8706
9832
761
3590
784
1133
4762
7960
2588
704
9089
2205
317...

result:

ok cost = 5702694

Subtask #2:

score: 0
Checker Time Limit Exceeded

Test #11:

score: 0
Checker Time Limit Exceeded

input:

100000 200000
-8961334 8961334
-7613572 -7613572
-3090937 3090937
8569374 8569374
-526841 526841
2030109 2030109
829999 -829999
6793124 6793124
-5100765 5100765
-4111697 4111697
5995701 5995701
-3387024 -3387024
1395655 -1395655
1161722 -1161722
7911524 7911524
307563 -307563
1112474 1112474
-131073...

output:

94129
128454
35700
180927
99469
34932
95414
69769
70470
11040
88929
100872
124861
57839
38218
107746
6491
122738
55191
7876
195348
79467
111662
100460
29675
111394
10855
91193
186934
73824
103287
93061
72931
2343
48162
67875
151663
77964
60507
75557
94854
26593
73504
125636
1172
77609
93686
1654
182...

result:


Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%