QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226957 | #7558. Abstract | ucup-team2307# | WA | 334ms | 80252kb | C++17 | 2.1kb | 2023-10-26 19:04:21 | 2023-10-26 19:04:21 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
#define int ll
const __int128 base = __int128(1) << 120;
const int sz = 7e4 / 120;
typedef array<__int128, sz> superll;
void add(superll& x, const superll& y)
{
__int128 carry = 0;
for (int i=0; i<sz; i++)
{
x[i] = (x[i] + 2*y[i] + carry)%base;
carry = (x[i] + 2*y[i] + carry)/base;
}
}
vector<int> g[100500];
vector<int> gr[100500];
int a[10500];
bool used[10500];
superll dp[10500];
void dfs(int v)
{
if (used[v])
return;
for (int i=1; i<sz; i++)
dp[v][i] = 0;
dp[v][0] = a[v];
used[v] = true;
for (int i : gr[v])
{
dfs(i);
add(dp[v], dp[i]);
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout<<sz*16*10000 / 1e6<<"\n";
// return 0;
int n, m;
cin>>n>>m;
for(int i=1; i<=n; i++)
{
cin>>a[i];
}
for (int i=1; i<=m; i++)
{
int x, y;
cin>>x>>y;
g[x].pb(y);
gr[y].pb(x);
}
// n = 1e4;
// m = 1e5;
// for (int i=1; i<=n; i++)
// a[i] = 1e9;
// for (int i=1; i<n; i++)
// for (int j=1; j<=m/n; j++)
// {
// int x, y;
// x = i;
// y = i+1;
// g[x].pb(y);
// gr[y].pb(x);
// }
int x = 0;
for (int i=1; i<=n; i++)
if (g[i].size() == 0)
x = i;
dfs(x);
int last = -1;
for (int i=sz-1; i>=0; i--)
if (dp[x][i])
{
last = i;
break;
}
if (last == -1)
cout<<"0\n";
else
{
// cout<<last<<" "<<sz<<"\n";
// cout<<ll(dp[x][last])<<"\n";
int ans = last*120;
__int128 y = dp[x][last];
while (y > 0)
ans++, y/=2;
cout<<ans<<"\n";
}
}
/*
3 2
1 1 1
1 2
2 3
6 8
1 1 4 5 1 4
1 4
1 5
2 3
2 5
3 4
4 5
4 6
5 6
5 6
7 2 3 6 6
1 2
1 4
2 3
3 4
3 5
4 5
*/
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 8576kb
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: 9856kb
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: 9932kb
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: -100
Wrong Answer
time: 334ms
memory: 80252kb
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:
7442
result:
wrong answer 1st numbers differ - expected: '7344', found: '7442'