QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#368834 | #7558. Abstract | skyline# | WA | 40ms | 21972kb | C++20 | 1.2kb | 2024-03-27 16:55:34 | 2024-03-27 16:55:35 |
Judging History
answer
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mp make_pair
#define orz 1000000007
#define fi first
#define se second
using namespace std;
ll f[10005][265];
int n,m,cnt[10005],q[10005];
vector<int> v[10005],v2[10005];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;++i)cin>>f[i][1];
bool ok=0;
for(int i=1;i<=n;++i)if(f[i][1])ok=1;
if(!ok){
cout<<"0\n";
return 0;
}
for(int i=1;i<=m;++i){
int x,y;
cin>>x>>y;
++cnt[y];
v[y].pb(x);
v2[x].pb(y);
}
int qr=0;
for(int i=1;i<=n;++i)if(!cnt[i])q[++qr]=i;
for(int ql=1;ql<=qr;++ql){
int x=q[ql];
for(int i=0;i<v2[x].size();++i){
int y=v2[x][i];
--cnt[y];
if(!cnt[y])q[++qr]=y;
}
}
for(int i=1;i<=n;++i){
int x=q[i];
for(int i=0;i<v[x].size();++i){
int y=v[x][i];
for(int k=1;k<=262;++k)f[x][k]+=(f[y][k]<<1);
for(int k=1;k<=262;++k){
f[x][k+1]+=(f[x][k]>>62);
f[x][k]&=((1ll<<62)-1);
}
}
}
int x=q[n];
int k=262;
while(!f[x][k])--k;
int ans=(k-1)*62;
while(f[x][k]){
f[x][k]>>=1;
++ans;
}
cout<<ans<<'\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5660kb
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: 5616kb
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: 1ms
memory: 3596kb
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: 40ms
memory: 21972kb
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: -100
Wrong Answer
time: 33ms
memory: 12904kb
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:
3550
result:
wrong answer 1st numbers differ - expected: '3552', found: '3550'