QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#316788#8170. $N^a (\log N)^b$ucup-team992#Compile Error//C++201.0kb2024-01-28 03:55:202024-01-28 03:55:22

Judging History

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

  • [2024-01-28 03:55:22]
  • 评测
  • [2024-01-28 03:55:20]
  • 提交

answer

import sys
sys.setrecursionlimit(1000000)
F = input()
idx = 0

def peek():
	global idx
	if idx == len(F):
		return None
	return F[idx]

def expr():
	global idx
	ts = term()
	while peek() == '+':
		idx += 1
		ts = max(ts, term())
	return ts

def term():
	global idx
	fs = factor()
	while peek() == '*':
		idx += 1
		f2 = factor()
		fs[0] += f2[0]
		fs[1] += f2[1]
		fs[2] = fs[2] or f2[2]
	return fs

def factor():
	global idx
	if peek() == 'N':
		idx += 1
		v = 1
		if peek() == '^':
			idx += 1
			v = number()
		return [v, 0, False]
	if peek() == 'l':
		idx += 4 # log(
		ex = expr()
		idx += 1 #)
		v = 1
		if peek() == '^':
			idx += 1
			v = number()
		ex2 = [0, v if ex[0] > 0 else 0, (ex[1] > 0) or ex[2]]
		return ex2
	if peek() == '(':
		idx += 1
		ex = expr()
		idx += 1 #)
		return ex

def number():
	global idx
	i0 = idx
	while peek() in '0123456789':
		idx += 1
	return int(F[i0:idx])

R = expr()
if R[2]:
	R[1] += 1
print(R[0], R[1])








Details

answer.code:41:26: error: stray ‘#’ in program
   41 |                 idx += 4 # log(
      |                          ^
answer.code:43:26: error: stray ‘#’ in program
   43 |                 idx += 1 #)
      |                          ^
answer.code:53:26: error: stray ‘#’ in program
   53 |                 idx += 1 #)
      |                          ^
answer.code:59:25: warning: character constant too long for its type
   59 |         while peek() in '0123456789':
      |                         ^~~~~~~~~~~~
answer.code:1:1: error: ‘import’ does not name a type
    1 | import sys
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’, which is not yet enabled with ‘-std=c++20’