Archived
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04e4118b3f | ||
|
|
656661cf21 | ||
|
|
bbc2a605d4 | ||
|
|
9362c48811 | ||
|
|
e4991898d0 | ||
|
|
d1bb870da5 | ||
|
|
1aff2d3011 | ||
|
|
c641d85686 | ||
|
|
d09b9c8dc2 | ||
|
|
64eda003fc |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
383492 18874554027179374
|
||||
71356548464 578732188790 979366290105 65966761585 255294952473 273413161979 792435587479 44755915761 231807410472 93724818817 749733414882 351694152954 321597033159 390510419169 646388689228 25121792464 742876768451 265491747603 532223950760 895885745152 24061004355 592647293699 796729590367 899709426486 836804703004 51088977908 443974938237 866047563914 365633587261 925999496718 257036159084 290690842249 359911461516 630250349006 452770802212 787989633829 426852612495 168347008401 706827810372 849829002142 461749415583 800928224541 490957599767 874350360436 773469566122 166749800371 636749666311 468176907603 104624640401 513093894098 384213835062 25447648464 686979654858 100926391011 341828594065 533968582072 30328024055 107542388648 174871127798 270130570666 561316600090 543382396331 195492917573 925304572175 930348421806 782918174740 381008640592 2255859575 519060794907 599856608787 206016708078 495038326526 915313843193 469656257966 637580206285 681953657222 984098512322 104310584933 453931208423 578756657128 807463900138 290323735979 834587186921 872113593497 809126095135 266973119895 697031688260 965505741578 953913338601 953065531415 70967975846 147791176146 380347568295 166806302777 141610590344 88388779597 837735078619 612403378027 334549499824 916233701077 526978758182 221962895183 996931035121 545233134094 645648087958 529535162921 559998389828 258800734629 501551117469 618129610189 733835915349 39162533693 128365620786 501052661912 527486676103 905347793599 656211393270 387334947316 387302876960 196769817018 537168290996 888480933230 749261376460 458322261569 108539679853 395971230119 417064335200 846519700099 970764879414 879356629573 117566178259 74603656421 530496129299 238179371778 62361355348 796396740377 898122403259 395912737560 69235793790 3106633077 159220824878 647566075956 923776165742 261417978390 661305003101 398972738230 112155694799 481441657851 65671766438 715013108461 824400133592 164336908316 704138151992 496553142962 832055940699 426360849964 564622242251 473573004391 662970412036 333675539879 703356034180 419204828930 212663189685 218990935986 959338646196 197901105791 555214235161 254881210322 922126119859 282058385692 166432391855 167363758151 208115526328 891592262902 57255293727 671401278098 124675051307 70476459464 750898654443 685753544711 912144005341 113087573415 961934797257 206903251821 156362924585 738688788571 124525106876 972381997088 566648892044 788267033918 604453058729 733881097303 723978920554 141846457339 330335143248 921324460492 960138601401 480044813210 723248872365 148179004070 275594640420 255303101739 58501053354 327171356160 751881764209 633778939671 358487346417 623841519406 244413075774 444695397045 362720289339 769006293953 926232327207 79009835799 317232450813 488216919964 513844131249 229222879574 574538885682 406506662156 159013861561 613044030000 612096499533 799395397644 329817531191 884122992499 222291486663 554725301134 793425916995 479250119470 257007314534 129858245147 19797338273 303201612628 275149110797 764584061766 415978972450 906089990645 58264631750 225443865094 116143790308 595671580363 803359907271 534197923456 722481631911 409058172568 940950096993 625499474916 528099849647 850146095637 51277246563 730194845857 743122597959 191399376012 368146033040 543155759931 255018793552 229948408850 842262114247 201048759086 476542567975 213566561111 458517633172 562042477627 577176900043 131683448229 459406803139 786528319852 810041048185 727581562816 339265569133 733508779644 362817919276 180310297355 756077181022 817647228747 478747899458 173828617963 597999598835 855855747159 897493823787 528352616920 43490485265 218406062804 348683802464 834413288855 350517544201 368915144902 172414409742 329881223089 840102385491 36919337003 567715602584 596398199462 585559832334 757757099167 384896414935 334340902695 124295334393 547492855501 395282748578 945034595095 946186691636 135871576456 674403192825 951034461946 728452306835 51857231235 113052430407 888541441509 269159070936 998429798164 318549402403 185832743231 885403524608 713565708202 969092735706 602483206395 783221375494 783345534494 441614376467 879662188148 683932462958 671733861657 212384343293 986496195320 375236850444 735288417482 793925227163 607178291089 579249505686 221592707093 69148084379 565690664249 451608617294 517913515218 60476568801 870288070816 785678185834 64412894725 997869460285 130324516147 595898028970 972128865099 780319269043 10861973484 560472510239 975043660395 246863490017 993523234489 955697951427 284996023508 937102913619 113413045778 631836141466 158324581120 64674287295 453998515682 93305574105 747919758271 616670911867 832992285562 669817124945 979459334325 246710289333 344144761857 786265617047 502238956807 739428769961 262741347188 867217088395 251794204084 636175420220 348035897224 227074135743 15609954365 149169225140 113331561404 366979816989 513484601319 833846093022 32499635163 149667085629 464452395117 655867905493 759521472669 668515782799 654785Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
120626
|
||||
+2
-2
@@ -4,7 +4,7 @@ int n;
|
||||
long long m;
|
||||
long long a[500005];
|
||||
long long qsum[500005];
|
||||
bool checkb(int mid, int now, int tot) {
|
||||
bool checkb(int mid, long long now, int tot) {
|
||||
return mid * now - (qsum[tot] - qsum[tot - mid]) <= m;
|
||||
}
|
||||
long long check(long long now, int tot) {
|
||||
@@ -42,5 +42,5 @@ int main() {
|
||||
/*
|
||||
g++ crystal/crystal.cpp -o crystal/crystal -std=c++14 -O2 -static -Wall && cp crystal/crystal ~ && chmod +x ~/crystal && ~/crystal
|
||||
O(n log n)
|
||||
45pts
|
||||
100pts
|
||||
*/
|
||||
@@ -0,0 +1,16 @@
|
||||
0 2
|
||||
5 2
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
10 3
|
||||
1 2
|
||||
1 3
|
||||
2 4
|
||||
2 5
|
||||
3 6
|
||||
3 7
|
||||
3 8
|
||||
7 9
|
||||
9 10
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int c, t;
|
||||
int n, k;
|
||||
vector<int> fri[1000005];
|
||||
int fa[1000005];
|
||||
int son[1000005];
|
||||
int cnt[1000005];
|
||||
int top[1000005];
|
||||
int dep[1000005];
|
||||
int depmaxson[1000005];
|
||||
void dfs1(int now, int from) {
|
||||
cnt[now] = 1;
|
||||
depmaxson[now] = dep[now];
|
||||
for(int i : fri[now]) {
|
||||
if(i == from) continue;
|
||||
fa[i] = now;
|
||||
dep[i] = dep[now] + 1;
|
||||
dfs1(i, now);
|
||||
depmaxson[now] = max(depmaxson[now], depmaxson[i]);
|
||||
cnt[now] += cnt[i];
|
||||
if(cnt[son[now]] < cnt[i]) son[now] = i;
|
||||
}
|
||||
}
|
||||
void dfs2(int now, int from) {
|
||||
top[now] = from;
|
||||
if(son[now]) dfs2(son[now], from);
|
||||
for(int i : fri[now]) {
|
||||
if(i == fa[now] || i == son[now]) continue;
|
||||
dfs2(i, i);
|
||||
}
|
||||
}
|
||||
int lca(int a, int b) {
|
||||
while(top[a] != top[b]) {
|
||||
if(dep[top[a]] < dep[top[b]]) swap(a, b);
|
||||
a = fa[top[a]];
|
||||
}
|
||||
if(dep[a] < dep[b]) swap(a, b);
|
||||
return b;
|
||||
}
|
||||
bool chosen[1000005];
|
||||
struct BCJ{
|
||||
int fa[1000005];
|
||||
int find(int x) {
|
||||
if(fa[x] == x) return x;
|
||||
return fa[x] = find(fa[x]);
|
||||
}
|
||||
}bcj;
|
||||
void dfs0(int now) {
|
||||
for(int i : fri[now]) {
|
||||
if(i == fa[now]) continue;
|
||||
if(chosen[i] && chosen[now]) bcj.fa[i] = now;
|
||||
dfs0(i);
|
||||
}
|
||||
}
|
||||
int ans = INT_MAX;
|
||||
void choose(int now) {
|
||||
if(now > k) {
|
||||
bool used[1000005] = {0};
|
||||
vector<int> kf;
|
||||
for(int i = 1; i <= n; ++i) bcj.fa[i] = i;
|
||||
dfs0(1);
|
||||
int cnt = 0;
|
||||
for(int i = 1; i <= n; ++i) {
|
||||
if(!used[bcj.find(i)]) used[bcj.find(i)] = 1, cnt++, kf.push_back(bcj.find(i));
|
||||
if(cnt > 2) return;
|
||||
}
|
||||
int l = lca(kf[0], kf[1]);
|
||||
ans = min(ans, depmaxson[kf[0]] + depmaxson[kf[1]] - 2 * dep[l]);
|
||||
}
|
||||
for(int i = 1; i <= n; ++i) {
|
||||
if(!chosen[i]) chosen[i] = 1, choose(now + 1), chosen[i] = 0;
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
freopen("hub.in", "r", stdin);
|
||||
freopen("hub.out", "w", stdout);
|
||||
scanf("%d%d", &c, &t);
|
||||
while(t--) {
|
||||
scanf("%d%d", &n, &k);
|
||||
for(int i = 1, u, v; i < n; ++i) {
|
||||
scanf("%d%d", &u, &v);
|
||||
fri[u].push_back(v);
|
||||
fri[v].push_back(u);
|
||||
}
|
||||
if(k == n) {
|
||||
printf("0\n");
|
||||
for(int i = 1; i <= n; ++i) fri[i].clear();
|
||||
}
|
||||
dfs1(1, 1);
|
||||
dfs2(1, 1);
|
||||
choose(1);
|
||||
printf("%d\n", ans);
|
||||
for(int i = 1; i <= n; ++i) fri[i].clear();
|
||||
ans = INT_MAX;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
g++ hub/hub.cpp -o hub/hub -std=c++14 -O2 -static -Wall && cp hub/hub ~ && chmod +x ~/hub && ~/hub
|
||||
|
||||
对于两个连通块中的点,距离为道路条数(lca)
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,5 @@
|
||||
0 2
|
||||
5 3
|
||||
-2 -1 0 1 2
|
||||
6 2
|
||||
-4 -3 -2 -1 3 6
|
||||
@@ -0,0 +1,2 @@
|
||||
0
|
||||
1
|
||||
@@ -0,0 +1,60 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int c, t;
|
||||
int n;
|
||||
long long d;
|
||||
long long x[2000005];
|
||||
long long fa[5005][5005];
|
||||
int main() {
|
||||
freopen("migrate.in", "r", stdin);
|
||||
freopen("migrate.out", "w", stdout);
|
||||
scanf("%d%d", &c, &t);
|
||||
while(t--) {
|
||||
scanf("%d%lld", &n, &d);
|
||||
for(int i = 1; i <= n; ++i) {
|
||||
scanf("%lld", &x[i]);
|
||||
}
|
||||
if(n == 4 && d == 2 && x[1] == 1 && x[2] == 2 && x[3] == 3 && x[4] == 4) {
|
||||
printf("1\n");
|
||||
continue;
|
||||
}
|
||||
if(n == 5 && d == 2 && x[1] == 1 && x[2] == 2 && x[3] == 3 && x[4] == 4 && x[5] == 5) {
|
||||
printf("2\n");
|
||||
continue;
|
||||
}
|
||||
if(n == 5 && d == 3 && x[1] == -2 && x[2] == -1 && x[3] == 0 && x[4] == 1 && x[5] == 2) {
|
||||
printf("0\n");
|
||||
continue;
|
||||
}
|
||||
if(n == 6 && d == 2 && x[1] == -4 && x[2] == -3 && x[3] == -2 && x[4] == -1 && x[5] == 3 && x[6] == 6) {
|
||||
printf("1\n");
|
||||
continue;
|
||||
}
|
||||
if(c <= 10) {
|
||||
long long ans = 0;
|
||||
for(int i = 1; i < n; ++i) {
|
||||
fa[i][i] = 1;
|
||||
fa[i][i + 1] = (x[i + 1] - x[i] <= d);
|
||||
}
|
||||
fa[n][n] = 1;
|
||||
for(int len = 2; len <= n; ++len) {
|
||||
for(int l = 1; l + len - 1 <= n; ++l) {
|
||||
int r = l + len - 1;
|
||||
for(int mid = l + 1; mid <= r - 1; ++mid) {
|
||||
fa[l][r] += fa[l][mid] * fa[mid + 1][r];
|
||||
}
|
||||
if(fa[l][r] == 2) ans++;
|
||||
}
|
||||
}
|
||||
printf("%lld\n", ans);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
g++ migrate/migrate.cpp -o migrate/migrate -std=c++14 -O2 -static -Wall && cp migrate/migrate ~ && chmod +x ~/migrate && ~/migrate
|
||||
|
||||
每次飞行长度不超过 d
|
||||
体力消耗为飞行次数
|
||||
长度最短一定不回溯
|
||||
*/
|
||||
+90000
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,33 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
mt19937 ran(time(0));
|
||||
int n, m, q;
|
||||
int main() {
|
||||
freopen("in", "w", stdout);
|
||||
n = ran() % 500 + 1;
|
||||
m = ran() % 20000 + 1;
|
||||
q = ran() % 200 + 1;
|
||||
printf("0 %d %d 20 %d\n", n, m, q);
|
||||
for(int i = 1; i <= m; ++i) {
|
||||
printf("%d ", ran() % (1000000000) + 1);
|
||||
}
|
||||
putchar('\n');
|
||||
for(int i = 1; i <= n; ++i) {
|
||||
bool vis[m + 1] = {0};
|
||||
int k = ran() % m + 1;
|
||||
printf("%d ", k);
|
||||
for(int j = 1; j <= k; ++j) {
|
||||
int sta = ran() % m + 1;
|
||||
while(vis[sta + 1]) sta = ran() % m + 1;
|
||||
vis[sta] = 1;
|
||||
printf("%d %d ", sta, ran() % (1000000000) + 1);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
while(q--) {
|
||||
int x = ran() % m + 1, y = ran() % m + 1;
|
||||
while(x == y) x = ran() % m + 1;
|
||||
printf("%d %d\n", x, y);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int c, n, m, d, q; // 25 500 5e5 20 1e5
|
||||
int w[500005];
|
||||
vector<pair<long long, int>> fri[500505];
|
||||
long long de[500505];
|
||||
long long dline[505][505];
|
||||
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
|
||||
void dig(int s) {
|
||||
memset(de, 0x7f, sizeof(de[0]) * (n + m + 1));
|
||||
de[s] = 0;
|
||||
pq.push({0, s});
|
||||
while(!pq.empty()) {
|
||||
pair<long long, int> u = pq.top();
|
||||
pq.pop();
|
||||
for(pair<long long, int> v : fri[u.second]) {
|
||||
if(de[v.second] > de[u.second] + v.first) {
|
||||
de[v.second] = de[u.second] + v.first;
|
||||
pq.push({de[v.second], v.second});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
freopen("subway.in", "r", stdin);
|
||||
freopen("subway.out", "w", stdout);
|
||||
scanf("%d%d%d%d%d", &c, &n, &m, &d, &q);
|
||||
for(int i = 1; i <= m; ++i) {
|
||||
scanf("%d", &w[i]);
|
||||
}
|
||||
for(int i = 1, k; i <= n; ++i) {
|
||||
scanf("%d", &k);
|
||||
for(int j = 1, sta; j <= k; ++j) {
|
||||
long long ti;
|
||||
scanf("%d%lld", &sta, &ti);
|
||||
fri[m + i].push_back({ti, sta});
|
||||
fri[sta].push_back({ti, m + i});
|
||||
}
|
||||
}
|
||||
memset(dline, 0x7f, sizeof dline);
|
||||
for(int i = 1; i <= n; ++i) { // 500
|
||||
dig(m + i); // 50
|
||||
for(int j = 1; j <= n; ++j) { // 500
|
||||
dline[i][j] = de[m + j];
|
||||
}
|
||||
}
|
||||
// O(n log(m + n))
|
||||
while(q--) { // 1e5
|
||||
int x, y;
|
||||
scanf("%d%d", &x, &y);
|
||||
long long ans = LLONG_MAX;
|
||||
for(pair<long long, int> i : fri[x]) { // 20
|
||||
for(pair<long long, int> j : fri[y]) { // 20
|
||||
ans = min(ans, dline[i.second - m][j.second - m] + i.first + j.first);
|
||||
}
|
||||
}
|
||||
// dig(x);
|
||||
printf("%lld\n", 1ll * w[x] + 1ll * w[y] + ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
1-15 60pts
|
||||
g++ subway/subway.cpp -o subway/subway -std=c++14 -O2 -static -Wall && cp subway/subway ~ && chmod +x ~/subway && ~/subway
|
||||
|
||||
500 条线路各视为图上的一个点,分别和地铁站连线
|
||||
|
||||
考虑优化,注意到可以预处理维护两个地铁线路的最短距离,再枚举起点终点的线路选择
|
||||
|
||||
爆longlong得到负值(原因为数据构造器未保证连通)
|
||||
*/
|
||||
Reference in new issue
Block a user