QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#563354 | #7558. Abstract | huaxiamengjin | RE | 1ms | 10024kb | C++14 | 918b | 2024-09-14 10:24:13 | 2024-09-14 10:24:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[100100];
int deg[100100];
int f[1010][1010];
queue<int>q;
int ans;
vector<int>g[100100];
int main(){
cin>>n>>m;
for (int i=1;i<=n;i++)
cin>>a[i];
for (int i=1,x,y;i<=m;i++)
cin>>x>>y,g[x].push_back(y),
deg[y]++;
for (int i=1;i<=n;i++)
if(deg[i]==0)q.push(i);
int nn=n+30;
for (int i=1;i<=n;i++){
for (int j=0;j<=30;j++)
if(a[i]>>j&1)f[i][j]=1,ans=max(ans,j+1);
}
while(q.size()){
int x=q.front();q.pop();
for (int i=0;i<=nn;i++)
if(f[x][i]==1)ans=max(ans,i+1);
for (auto y:g[x]){
for (int i=1;i<=nn;i++){
f[y][i]+=f[x][i-1];
if(f[y][i]>1)f[y][i+1]+=f[y][i]/2,f[y][i]&=1;
}
deg[y]--;
if(deg[y]==0)q.push(y);
}
}
cout<<ans<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 10024kb
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: 6952kb
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: 7656kb
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
Runtime Error
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...