QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207560#7558. Abstractucup-team870Compile Error//C++20775b2023-10-08 17:04:162023-10-08 17:04:17

Judging History

你现在查看的是最新测评结果

  • [2023-10-08 17:04:17]
  • 评测
  • [2023-10-08 17:04:16]
  • 提交

answer

nm=input().split()
n=int(nm[0]); m=int(nm[1])
a=[]
tu=[]
deg=[]
q=[]
c=[]
for i in range(0,n+1): 
    a.append(0); deg.append(0); q.append(0); c.append(0)
    tu.append([])
arr=input().split()
for i in range(1,n+1):
    a[i]=int(arr[i-1])
    # print(a[i])
for _ in range(m):
    uv=input().split()
    u=int(uv[0]); v=int(uv[1])
    deg[u]+=1
    tu[v].append(u)
x=-1
for i in range(1,n+1):
    if deg[i]==0: x=i
assert x!=-1
L=1; R=1
q[1]=x; c[x]=1
while L<=R:
    now=q[L]; L+=1
    # print(now,c[now])
    for u in tu[now]:
        deg[u]-=1; c[u]+=2*c[now]
        if deg[u]==0:
            R+=1; q[R]=u
assert R==n
sum=0
for i in range(1,n+1):
    sum+=c[i]*a[i]
    # print(i,sum)
ans=0
while sum:
    sum//=2; ans+=1
print(ans)

Details

answer.code:14:7: error: invalid preprocessing directive #print
   14 |     # print(a[i])
      |       ^~~~~
answer.code:28:7: error: invalid preprocessing directive #print
   28 |     # print(now,c[now])
      |       ^~~~~
answer.code:37:7: error: invalid preprocessing directive #print
   37 |     # print(i,sum)
      |       ^~~~~
answer.code:1:1: error: ‘nm’ does not name a type
    1 | nm=input().split()
      | ^~
answer.code:2:15: error: ‘m’ does not name a type
    2 | n=int(nm[0]); m=int(nm[1])
      |               ^
answer.code:9:18: error: ‘deg’ does not name a type
    9 |     a.append(0); deg.append(0); q.append(0); c.append(0)
      |                  ^~~
answer.code:9:33: error: ‘q’ does not name a type
    9 |     a.append(0); deg.append(0); q.append(0); c.append(0)
      |                                 ^
answer.code:9:46: error: ‘c’ does not name a type
    9 |     a.append(0); deg.append(0); q.append(0); c.append(0)
      |                                              ^
answer.code:17:19: error: ‘v’ does not name a type
   17 |     u=int(uv[0]); v=int(uv[1])
      |                   ^
answer.code:24:6: error: ‘R’ does not name a type
   24 | L=1; R=1
      |      ^
answer.code:25:9: error: ‘c’ does not name a type
   25 | q[1]=x; c[x]=1
      |         ^
answer.code:27:15: error: ‘L’ does not name a type
   27 |     now=q[L]; L+=1
      |               ^
answer.code:30:20: error: ‘c’ does not name a type
   30 |         deg[u]-=1; c[u]+=2*c[now]
      |                    ^
answer.code:32:19: error: ‘q’ does not name a type
   32 |             R+=1; q[R]=u
      |                   ^