QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204264 | #7558. Abstract | ucup-team918# | WA | 6ms | 6772kb | C++17 | 3.7kb | 2023-10-07 08:26:11 | 2023-10-07 08:26:12 |
Judging History
answer
//Was yea ra,rra yea ra synk sphilar yor en me exec hymme METAFALICA waath!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long
#define ull unsigned ll
#define lowbit(x) (x&(-x))
#define djq 1000000007
const short sint=0x3f3f;
const int inf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;
const double alpha=0.73;
const double PI=acos(-1);
inline void file(){
freopen("ball.in","r",stdin);
freopen("ball.out","w",stdout);
}
char buf[1<<21],*p1=buf,*p2=buf;
inline int getc(){
return p1==p2&&(p2=(p1=buf)+fread(buf,1,(1<<20)+5,stdin),p1==p2)?EOF:*p1++;
}
//#define getc getchar
inline ll read(){
rg ll ret=0,f=0;char ch=getc();
while(!isdigit(ch)){if(ch==EOF)exit(0);if(ch=='-')f=1;ch=getc();}
while(isdigit(ch)){ret=ret*10+ch-48;ch=getc();}
return f?-ret:ret;
}
inline int rdstr(char* s){
char ch=getc(); int len(0);
while(ch<33||ch>126) ch=getc();
while(ch>=33&&ch<=126) (*s++)=ch,++len,ch=getc();
return len;
}
#define ep emplace
#define epb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define it iterator
#define mkp make_pair
#define naive return 0*puts("Yes")
#define angry return 0*puts("No")
#define fls fflush(stdout)
#define rep(i,a) for(rg int i=1;i<=a;++i)
#define per(i,a) for(rg int i=a;i;--i)
#define rep0(i,a) for(rg int i=0;i<=a;++i)
#define per0(i,a) for(rg int i=a;~i;--i)
#define szf sizeof
typedef vector<int> vec;
typedef pair<int,int> pii;
struct point{ int x,y; point(int x=0,int y=0):x(x),y(y) {} inline bool operator<(const point& T)const{ return x^T.x?x<T.x:y<T.y; }; };
inline int ksm(int base,int p){int ret=1;while(p){if(p&1)ret=1ll*ret*base%djq;base=1ll*base*base%djq,p>>=1;}return ret;}
inline void pls(int& x,const int k){ x=(x+k>=djq?x+k-djq:x+k); }
inline int add(const int a,const int b){ return a+b>=djq?a+b-djq:a+b; }
inline void sub(int& x,const int k){ x=(x-k<0?x-k+djq:x-k); }
inline int inc(const int a,const int b){ return a<b?a-b+djq:a-b; }
inline void ckmn(int& x,const int k){ x=(k<x?k:x); }
inline void ckmx(int& x,const int k){ x=(k>x?k:x); }
inline void ckmn(ll& x,const ll k){ x=(k<x?k:x); }
inline void ckmx(ll& x,const ll k){ x=(k>x?k:x); }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
namespace bigint{
typedef vector<ll> bint;
const int base=1<<30;
inline void print(bint x){
vec tmp; const int n=x.size();
for(rg int i=0;i<n;++i) for(rg int j=0;j<9;++j) tmp.epb(x[i]%10),x[i]/=10;
while(tmp.back()==0) tmp.pop_back();
if(tmp.empty()) tmp.epb(0);
const int m=tmp.size();
for(rg int i=m-1;~i;--i) printf("%d",tmp[i]); puts("");
}
inline bint get(int x){ return bint(1,x); }
inline bint operator+(const bint& x,const bint& y){
const int lx=x.size(),ly=y.size(),n=max(lx,ly); bint z; z.resize(n);
for(rg int i=0;i<lx;++i) z[i]+=x[i];
for(rg int i=0;i<ly;++i) z[i]+=y[i];
ll r=0,q=0;
for(rg int i=0;i<n;++i) q=(r+z[i])/base,z[i]=(r+z[i])%base,r=q;
while(r) z.epb(r%base),r/=base;
return z;
}
}
using namespace bigint;
bint f[10005];
int n,m,deg[10005],dep[10005],tot,ord[10005];
ll a[10005];
vec e[10005];
signed main(){
//file();
n=read(),m=read();
rep(i,n) a[i]=read(),f[i]=get(a[i]);
rep(i,m){
const int u=read(),v=read();
e[u].epb(v); ++deg[v];
}
rep(i,n) if(!deg[i]) ord[++tot]=i;
rep(i,n){
const int x=ord[i];
for(int y:e[x]){
f[y]=f[y]+f[x];
dep[y]=dep[x]+1;
if(!--deg[y]) ord[++tot]=y;
}
}
const int len=f[ord[n]].size();
const int ans=dep[ord[n]]+(len-1)*30+__lg(f[ord[n]][len-1]);
printf("%d\n",ans);
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4300kb
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: 4308kb
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: 4248kb
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: 6ms
memory: 6772kb
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:
7812
result:
wrong answer 1st numbers differ - expected: '7344', found: '7812'