QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#501423 | #7558. Abstract | ucup-team1525 | WA | 41ms | 63904kb | C++17 | 1.6kb | 2024-08-02 18:19:33 | 2024-08-02 18:19:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int B = 40;
const ll W = 1ll << B;
int n, m;
const int N = 10005;
vector<int> e[N], ord;
int d[N];
struct bigint {
int len;
ll a[1005];
} a[N];
bigint operator+(const bigint &x, const bigint &y) {
bigint z;
z.len = max(x.len, y.len);
ll t = 0;
for (int i = 0; i < z.len; i++) {
z.a[i] = t + x.a[i] + y.a[i];
t = (z.a[i] >> B);
z.a[i] = (z.a[i] & (W - 1));
}
while (t) {
z.a[z.len] = (t & (W - 1));
z.len++;
t >>= B;
}
return z;
}
int bl(ll x) {
int sum = 0;
while (x) {
++sum;
x >>= 1;
}
return sum - 1;
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1, x; i <= n; ++i) {
scanf("%d", &x);
a[i].len = 1;
a[i].a[0] = x;
}
for (int i = 1, u, v; i <= m; ++i) {
scanf("%d%d", &u, &v);
e[u].push_back(v);
d[v]++;
}
queue<int> q;
for (int i = 1; i <= n; ++i)
if (d[i] == 0)
q.push(i);
while (!q.empty()) {
int x = q.front();
q.pop();
ord.push_back(x);
for (int y : e[x]) {
--d[y];
if (!d[y])
q.push(y);
}
}
for (int x : ord) {
a[x] = a[x] + a[x];
for (int y : e[x])
a[y] = a[x] + a[y];
}
int o = ord.back();
if (a[o].len == 1 && a[o].a[0] == 0) {
puts("0");
return 0;
}
cout << ((a[o].len - 1) * B + bl(a[o].a[a[o].len - 1])) << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3940kb
input:
3 2 1 1 1 1 2 2 3
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5960kb
input:
6 8 1 1 4 5 1 4 1 4 1 5 2 3 2 5 3 4 4 5 4 6 5 6
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
5 6 7 2 3 6 6 1 2 1 4 2 3 3 4 3 5 4 5
output:
9
result:
ok 1 number(s): "9"
Test #4:
score: 0
Accepted
time: 41ms
memory: 63904kb
input:
7286 80481 637288250 628935175 588324396 766398783 663989874 865498593 695497968 630237220 19939888 448367842 412696777 111291257 304805809 585852799 58270069 391993802 606944382 827515045 389862501 643981354 160381074 324288921 257053597 980043955 417281046 870855665 360154617 60327683 966755927 55...
output:
7344
result:
ok 1 number(s): "7344"
Test #5:
score: 0
Accepted
time: 31ms
memory: 33212kb
input:
3485 69345 126919335 553087878 429357681 107790917 253972208 821989783 176128117 334722143 34989524 671942525 903789117 265616010 293291124 132216887 707703503 418751992 884191319 759015972 55466567 99122540 354621491 27107365 365748390 577882877 170254553 988104760 599408763 810052334 913007827 481...
output:
3552
result:
ok 1 number(s): "3552"
Test #6:
score: 0
Accepted
time: 22ms
memory: 41620kb
input:
4689 60385 379526147 320297565 290144701 411659092 808895255 349467622 912526797 945207025 147304164 611762485 690455633 593862503 349796612 915342714 685542590 669277310 101349964 538393690 204894013 843271709 963886266 502004930 826860359 607900073 348962474 135953765 54884804 334093983 550287693 ...
output:
4735
result:
ok 1 number(s): "4735"
Test #7:
score: 0
Accepted
time: 10ms
memory: 21884kb
input:
2025 13466 126370676 243460503 613061215 640378899 861853110 677538246 285817021 986777516 15580136 316176404 626530661 279208872 907269727 867851232 311220916 469724204 74428615 32310082 942939721 177419954 762441651 262073944 202700718 559297816 358074717 198943661 440995981 349418644 741410433 25...
output:
2067
result:
ok 1 number(s): "2067"
Test #8:
score: 0
Accepted
time: 1ms
memory: 6576kb
input:
121 199 896493283 602876262 190412813 539005355 361393375 336898107 57573022 860831181 796613695 697555446 474410296 573506583 646847982 775622764 433638751 410211736 706262484 308743162 694033299 787089776 557626422 410409760 666965625 606229683 774588923 213849175 739959306 318954654 193492757 624...
output:
153
result:
ok 1 number(s): "153"
Test #9:
score: 0
Accepted
time: 35ms
memory: 46864kb
input:
5173 82801 972178880 55787886 726219846 273505188 14833165 37678608 275433188 549410719 708739346 1596684 204453484 945870857 502585545 308710857 846757497 570148074 483775449 435833419 921907607 261743006 297037496 320466454 792975799 516106710 589464190 376914168 858666582 446429120 925757959 8940...
output:
5233
result:
ok 1 number(s): "5233"
Test #10:
score: 0
Accepted
time: 35ms
memory: 42228kb
input:
4451 68751 734143298 168118925 474566099 914135738 175189225 854565096 725921855 150734745 33215980 472643707 815730766 973287826 824133531 440222648 918212826 837679353 7350350 167875290 528553053 937486333 615587529 256295189 480035843 489273798 172853737 135811440 968971168 925087779 375176970 33...
output:
4514
result:
ok 1 number(s): "4514"
Test #11:
score: 0
Accepted
time: 24ms
memory: 24352kb
input:
2383 58762 509075060 867612403 21996053 527466121 553589454 671190283 764167183 890805913 862657253 922878788 744689887 170690927 609890819 40416579 350962700 185478150 75096314 104961883 754430815 421417968 778490115 468058225 431868239 303651678 581681467 384545786 339203220 559058549 941951463 37...
output:
2467
result:
ok 1 number(s): "2467"
Test #12:
score: -100
Wrong Answer
time: 30ms
memory: 23888kb
input:
2001 67457 723197687 478813608 232810746 428945491 429136421 648852717 544540978 369132456 184435370 343975895 585223464 502157635 503001231 386021746 670322194 813441457 170390807 934181094 930734781 209174515 312012184 837865721 956809810 794424618 401909501 180498703 669648434 783741686 378051289...
output:
2104
result:
wrong answer 1st numbers differ - expected: '2102', found: '2104'