QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#135786 | #3871. Voting Cities | Mohammed_Atalah# | 0 | 3ms | 4340kb | C++17 | 2.1kb | 2023-08-06 00:29:02 | 2024-07-04 01:18:01 |
Judging History
answer
/// Template path: /home/mohammed/.config/sublime-text-3/Packages/User
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vecint;
typedef vector<char> vecchar;
typedef vector<string> vecstr;
typedef vector<long long> vecll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// Marcos
#define endl ("\n")
#define int long long
#define mod 1000000007
#define pi (3.141592653589)
#define REP(i,a,b) for (int i = a; i < b; i++)
#define RREP(i,a,b) for (int i = a; i > b; i--)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
// Functions
long long squared(long long x) {return (x * x) % mod;}
int factorial(int n) {long long res = 1; for (int i = 1; i <= n; i++) {res = ((res * i) % mod + mod) % mod ;} return res;}
long long power(long long x, long long p) {if (p == 0) {return 1;} if (p % 2 == 1) {return (power(x, p - 1) * x) % mod;} return squared(power(x, p / 2));}
// cout << fixed;
// cout << setprecision(4);
// ---------(^_^)--------- //
vector<vector<vector<int>>> edg;
vector<int> cost;
vector<int> vis;
void dfs(int idx, int c) {
cost[idx] = c;
for (auto &i : edg[idx]) {
if (vis[i[0]]) continue;
vis[i[0]]++;
dfs(i[0], c + i[1]);
vis[i[0]]--;
}
}
void main_solve() {
int n, e, k; cin >> n >> e >> k;
cin >> k;
cost.resize(n, -1);
vis.resize(n);
edg.resize(n);
for (int i = 0; i < e; i ++) {
int a, b, c; cin >> a >> b >> c;
edg[b].push_back({a, c});
}
vis[k]++;
dfs(k, 0);
int q; cin >> q;
while (q--) {
int s, p1, p2, p3, p4, p5;
cin >> s >> p1 >> p2 >> p3 >> p4 >> p5;
cout << cost[s] << endl;
}
}
int32_t main() {
fast;
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
// Just another problem (-_-)
int t;
t = 1;
// cin >> t;
while (t--) {
main_solve();
}
}
详细
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
5000 10000 1 4683 0 715 579327370 0 954 664830350 0 2453 244225980 0 2918 399241150 0 3929 982683290 1 4944 723915200 2 3725 390369490 3 1370 230814450 3 3348 750421430 3 3408 503334040 4 252 852709300 4 989 474431070 4 1013 466847840 4 4956 152207550 5 4162 271201150 6 3335 991911830 6 3596 4382854...
output:
result:
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 0
Time Limit Exceeded
input:
5000 10000 1 939 0 1074 697931020 0 4334 347738890 1 2400 681303040 2 1685 896587820 2 2368 928896100 2 3133 12276450 2 3258 765661210 4 3606 993201320 5 1081 613705100 5 2339 700470170 5 2625 209307440 5 2832 129029550 7 1517 251821020 7 1751 713428320 7 2308 951691550 7 3980 498317440 7 4014 78197...
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #11:
score: 0
Runtime Error
input:
5000 10000 2000 366 1016 3277 5 3742 3640 2511 1725 2168 2349 1037 4972 2930 4374 3504 1098 3439 3970 1952 3474 2664 2097 1751 3679 3155 3266 2070 2016 338 1273 2648 4398 3694 2045 3524 1027 839 1898 1795 1192 2975 1756 4707 1548 4984 1891 2364 123 3181 1096 2970 3264 1628 1295 4852 829 4940 2251 37...
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #16:
score: 5
Accepted
time: 3ms
memory: 4340kb
input:
5000 10000 1 4577 0 248 57534230 0 3020 827662530 0 3190 138424730 1 3154 752916230 4 1256 398736840 5 4116 833556610 5 4127 547494700 6 396 793865570 6 1661 388141660 7 4581 595148940 8 3768 724151300 9 1367 840320860 9 1656 391917460 10 3210 806346090 10 3356 767016610 10 3367 272248610 12 1145 72...
output:
-1
result:
ok single line: '-1'
Test #17:
score: 0
Accepted
time: 2ms
memory: 4288kb
input:
5000 4999 1 1212 0 3971 436288070 1 2759 815489840 2 810 158593560 3 2832 492373670 4 2209 368268770 5 2482 801981570 6 989 201812580 7 4202 350017710 8 2772 560704100 9 2017 156669510 10 4682 92934580 11 3450 514756530 12 3306 895638580 13 4257 871378280 14 1872 922166080 15 1805 346581840 16 1128 ...
output:
1612805668230
result:
ok single line: '1612805668230'
Test #18:
score: -5
Time Limit Exceeded
input:
5000 10000 1 3608 0 1 810121220 0 2 355065080 0 2896 301650880 0 4717 386184700 2 3 950388340 3 4 477643040 4 5 241940330 4 6 187063440 4 7 130985470 4 2163 577070050 5 1203 806247670 6 3440 245643890 7 8 782485830 7 893 889883080 7 3541 5217960 8 9 942491640 8 11 207075260 8 12 202843280 8 3629 921...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Runtime Error
Test #22:
score: 0
Runtime Error
input:
5000 10000 200 1044 1225 1941 2497 4667 2566 3603 92 2261 1826 770 4780 127 4386 1948 2156 1504 4511 3119 4006 4473 389 3469 2670 3989 3092 55 670 4525 4965 1038 375 419 2599 4912 3665 4799 2997 4759 1660 1136 2308 1707 4249 3246 625 3378 52 734 4317 4958 3355 869 3361 2010 2300 2809 2635 2241 3441 ...
output:
result:
Subtask #7:
score: 0
Time Limit Exceeded
Test #26:
score: 0
Time Limit Exceeded
input:
100 1000 10 98 30 76 47 68 72 37 62 38 78 0 40 955510110 0 58 380472040 0 67 471726660 0 75 21910230 0 76 203779460 0 79 619337400 0 92 789108960 0 95 850838250 1 7 708430 1 8 800979960 1 24 529606990 1 25 822365030 1 40 803087030 1 75 339182160 1 79 841073850 1 86 249876300 1 92 93708160 2 6 653731...
output:
result:
Subtask #8:
score: 0
Skipped
Dependency #1:
0%