QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#315562#8170. $N^a (\log N)^b$ucup-team087#WA 7ms14872kbC++143.4kb2024-01-27 14:16:272024-01-27 14:16:29

Judging History

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

  • [2024-01-27 14:16:29]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:14872kb
  • [2024-01-27 14:16:27]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


char S[100'010];
int cur;
void eat(char tar) {
  if (S[cur] != tar) cerr << "[eat] FAIL " << cur << " " << S[cur] << " " << tar << endl;
  assert(S[cur] == tar);
  ++cur;
}

/*
⟨expr⟩ ::= ⟨term⟩ | ⟨expr⟩ ‘+’ ⟨term⟩
⟨term⟩ ::= ⟨factor⟩ | ⟨term⟩ ‘*’ ⟨factor⟩
⟨factor⟩ ::= ‘N’ | ‘N^’ ⟨number⟩ | ‘log(’ ⟨expr⟩ ‘)’ | ‘log(’ ⟨expr⟩ ‘)^’ ⟨number⟩ | ‘(’ ⟨expr⟩ ‘)’
⟨number⟩ ::= ⟨nonzero_digit⟩ | ⟨nonzero_digit⟩⟨digit_string⟩
⟨digit_string⟩ ::= ⟨digit⟩ | ⟨digit⟩⟨digit_string⟩
⟨nonzero_digit⟩ ::= ‘1’ | ‘2’ | ‘3’ | ‘4’ | ‘5’ | ‘6’ | ‘7’ | ‘8’ | ‘9’
⟨digit⟩ ::= ‘0’ | ⟨nonzero_digit⟩
*/
using P = pair<Int, pair<Int, Int>>;
P expr();
P term();
P factor();
Int number();

P expr() {
  P ret = term();
  for (; S[cur] == '+'; ) {
    eat('+');
    const P tmp = term();
    chmax(ret, tmp);
  }
  return ret;
}
P term() {
  P ret = factor();
  for (; S[cur] == '*'; ) {
    eat('*');
    const P tmp = factor();
    ret.first += tmp.first;
    ret.second.first += tmp.second.first;
    ret.second.second |= tmp.second.second;
  }
  return ret;
}
P factor() {
  P ret;
  if (S[cur] == 'N') {
    eat('N');
    Int e;
    if (S[cur] == '^') {
      eat('^');
      e = number();
    } else {
      e = 1;
    }
    ret = P(e, make_pair(0, 0));
  } else if (S[cur] == 'l') {
    eat('l');
    eat('o');
    eat('g');
    eat('(');
    const P tmp = expr();
    eat(')');
    Int e;
    if (S[cur] == '^') {
      eat('^');
      e = number();
    } else {
      e = 1;
    }
    ret = P(0, make_pair(tmp.first ? e : 0, (tmp.second.first + tmp.second.second) ? 1 : 0));
  } else {
    eat('(');
    ret = expr();
    eat(')');
  }
  return ret;
}
Int number() {
  Int x = 0;
  for (; isdigit(S[cur]); ) {
    (x *= 10) += (S[cur++] - '0');
  }
  return x;
}

int main() {
  for (; ~scanf("%s", S); ) {
    cur = 0;
    const auto ans = expr();
    printf("%lld %lld\n", ans.first, ans.second.first + (ans.second.second ? 1 : 0));
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3736kb

input:

N*log(N^2)*log(N)+N+log(N^1+N)^2*N

output:

1 2

result:

ok 2 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

N*log(log(N))

output:

1 1

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 1ms
memory: 3848kb

input:

(((N))*N^234567890+N^2)

output:

234567891 0

result:

ok 2 tokens

Test #4:

score: 0
Accepted
time: 1ms
memory: 3964kb

input:

log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)+log(N)...

output:

0 1

result:

ok 2 tokens

Test #5:

score: 0
Accepted
time: 1ms
memory: 3960kb

input:

log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)*log(N)...

output:

0 14285

result:

ok 2 tokens

Test #6:

score: 0
Accepted
time: 3ms
memory: 8200kb

input:

log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(...

output:

0 1

result:

ok 2 tokens

Test #7:

score: 0
Accepted
time: 7ms
memory: 14872kb

input:

((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

0 1

result:

ok 2 tokens

Test #8:

score: 0
Accepted
time: 1ms
memory: 3872kb

input:

log(log(N^39187693)^548521633+log(log(N*N^2+N*N^71962925)+log(N*N+N)*log(N+N)+log((log(log(N)^8))*log(log(N*N*N))))*log((N+log(N)*N+N*log(N)^958544341))^978444210)+log((log(N)^573073630)*log(log(N)^857299008)*(N+N^3+log(N))*log(N)+log(log(N^5943+((N*N)*N^3371597)+N*N*(N)*N^3732602)^195356379)^910014...

output:

0 706139983

result:

ok 2 tokens

Test #9:

score: 0
Accepted
time: 0ms
memory: 3956kb

input:

(log((N*log(log(log(N+N))+N*N+log(N*N*log(N)*N+N^88)*(log(N^39775+(N*N*N^39+(log((N^3509)))))^223188793))^106803375*(N*N*N*(N+N)*N^60976)*(log(log(N*N^8*(N*N)+N^4)+log(N)^87804)*log(log((N+N+N^63*N^49+N)+N)*log(N^24556108*log(N^28*(N)+log(N*N+(N)+log(N)^743*N))+N^86041+(N^276*(N+N+((N)))*log(N+N)^75...

output:

0 242619919

result:

ok 2 tokens

Test #10:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

log(log((((N)*N^60+(N+(N)*N))*N+(N+N)*log((log(N+log(N)^5)^99743452*(N*N*(N)*log(N)^849510749)))*log(N*N^13087+N)+log((N^1000000000*log(N)*N^388)*log(N*N^647*N*log((N^7)+N*N^445)+N)^908094458)^225370592+log((N+N^7467+log(N)^8852684)*log(((N)*N*log(N)^996)))^829473139+log(log((N*N)+N)^683248757*N^385...

output:

2474266 1883498746

result:

ok 2 tokens

Test #11:

score: 0
Accepted
time: 1ms
memory: 3960kb

input:

log(((log(log(log(log(log(log(N)^7)+N^80)*log(log(N+N+(N)+(N)+(N*N+log(N)*log((log(N*N))))*N^2*(log(log(log(N))^921759665)*(N*N)*(N^1)))*log(N+N*(N^409*(log(N+N*N)))*N^6))*(((N^9*N)*log((N+N*N)+N*log(N)^1+((N)*(N*(N+N)+N*N+(N)))))+log(log(log(log(N+N)^831866480)*log((N^633*log(log(N^323*(N))*N^5))*(...

output:

0 2

result:

ok 2 tokens

Test #12:

score: 0
Accepted
time: 1ms
memory: 3940kb

input:

(log(log((((log(log(log((N+N))^413593551)*(((N+N)*N*N*log((N)+N)))+(log(N+N+N+N*N^3+N)^336010059+N*N*log(N*N+N^19033)^825819051*log(N*(N)))+log(N+N+(N)*N*N^851241117*(log(N)^957547))^183676983)*(log((log(N*log(N)^5144*log((N*log((N)+log(N)^554955)))^426823799)^606862955*(((N)+N+N)+N^3)*((((N+log(log...

output:

0 561436137

result:

ok 2 tokens

Test #13:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

(log((log(log(log((log(N*N*N*(N))))+N+N*N*log(N^100065+N*(N*N)*N^8))^28051665*(log((log((N^4))*N^8)+log(N^458805*N^8+log(N))*log(N)^49+N*N*log(log(N)^75)^897477606)*log(log(log((log(N+log(log(N*N+N*N*N^40624)^262653064)+(N)))+log(N*N+log(N)^78*log(N+N^92+N^8)^396587715)^481112334*log(N+N*N*N+(N+N))^...

output:

1000000076 766522984

result:

ok 2 tokens

Test #14:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

log(log(log(N)))*(log(((log(N^1000000000+(N^62*N+N*N+log(N)^607183547)*(N*N+N^1000000000+N+N^1570*(N)))*log(N)^903326716*log((N)+log(N))*N^54+(log(log(N*N*N)^750819338)^635614262*log(log(N)*log(N)^490211+N^5+log(N)*N^14866)+log((N^4868))*((N)*(N+N*N^34+N))*log(log((((N+N))*log(N*N+N)^746670308))^987...

output:

0 519078288

result:

ok 2 tokens

Test #15:

score: 0
Accepted
time: 1ms
memory: 3936kb

input:

log(log(log(N)))*(log((log(N*(N*N)+N^96*N^5693*log((N+N+N*N+(N)))^953334725*(N*log(N)^485*log(log(N)^870*N)^906727886)*(log(N*N^82618772*log(N)^8*N)^219169093)*(log(N*N+N)^828072340)+(log(log((log(log((log(log(N)^240108*(N+N+N))^293692287+N*log(N+N*N)*log(N)^190624085)+log((N+N+(N)*N*log(N))*(N+N)*l...

output:

2 2

result:

ok 2 tokens

Test #16:

score: 0
Accepted
time: 1ms
memory: 3876kb

input:

log(log(log(N)))*((log(log(log(((log(N+N+N*N)^530184323*log(N))+log(N^627*(N*log(N)^427))))^126175816+log((N*N)+N)+log(log(N+(N)*(N+N)))+N^91796919*(log(log(N)^749818177+log(log(N*N+N+(N+N))+N*N)))+log(log(log(N*(log(N)^4480*N^99506943))*log(N+((N+N))*N))+N*N^2353*N^8))^212809542*log((N*N^65*(log(lo...

output:

0 915940921

result:

ok 2 tokens

Test #17:

score: 0
Accepted
time: 1ms
memory: 3940kb

input:

log(log(log(N)))*(((log(N+(log(N)+N*(N))*log(N+N))^798474828*(N*N+N*(N)+N)*log(N+N*N+log(N+N^62883435+N)+(N+N)*(N)*N^83877)+log(log(N)^56678*log((log(N*log(N)+N^29)^98989911))^527370914*log((log(N)^26883189)+log(N^7+N+N+N^996405+log(N*(N)*log(N))^33517755)+log(N+N+N))+log(N^373*(N)*log(N+N)^56626574...

output:

593433204 118198369

result:

ok 2 tokens

Test #18:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

log(log(N))^838581491*log(log(log(N)))^771838880*log(log(log(N)))^984794424*N^143685367*N^670902660*N^308600390*log(log(log(N)))^487833964*log(log(log(N)))^19986435*N^798013837*N^453144760*N^394168537*log(log(log(N)))^546955039*N^898890660*N^682322117*N^889322557*N^407917496*N^221994691*N^224405173*...

output:

679935528138 1

result:

ok 2 tokens

Test #19:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

log(log(log(N)))^711127206*N^185033389*N^571634726*N^800764746*N^761655533*log(log(N))^194596208*log(log(N))^473730093*N^942121502*log(log(log(N)))^943058044*N^406731292*N^784640780*N^907283134*N^771151830*N^237400284*log(log(log(N)))^4082846*log(log(log(N)))^553480158*N^83262231*N^185814435*log(log...

output:

1370636995419 1

result:

ok 2 tokens

Test #20:

score: 0
Accepted
time: 1ms
memory: 4024kb

input:

N^412975564*log(log(log(N)))^714491638*N^742156485*N^74449852*log(log(N))^188944493*log(log(log(N)))^143743726*log(log(N))^165136661*N^729772677*log(log(N))^621858429*N^778492004*N^694174771*N^266768497*log(log(N))^216295412*log(log(N))^478853380*N^847290570*N^334927888*N^625411332*N^628875800*log(l...

output:

1341926800671 1

result:

ok 2 tokens

Test #21:

score: 0
Accepted
time: 1ms
memory: 3876kb

input:

log(log(N))^434642403*N^440813390*log(log(log(N)))^301330411*N^753197419*log(log(N))^84423050*N^655998048*N^332499052*N^274185759*log(log(N))^494198745*N^616392008*log(log(N))^184812982*N^583431820*log(log(N))^681286109*log(log(N))^10068687*log(log(log(N)))^424129448*N^478422*log(log(N))^753177019*l...

output:

1382060561459 1

result:

ok 2 tokens

Test #22:

score: 0
Accepted
time: 0ms
memory: 4020kb

input:

log(log(log(N)))^766305539*N^634603577*log(log(log(N)))^173507038*log(log(N))^897033506*N^34630329*log(log(N))^291097249*N^485280920*N^645157708*N^694269808*N^273193565*N^643953068*log(log(N))^84740350*N^932801837*log(log(N))^387579512*log(log(N))^700638013*log(log(N))^718026139*log(log(N))^68036822...

output:

1410454687913 1

result:

ok 2 tokens

Test #23:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

log(N^56364*N*(N^14+((N^1)))*log(N)^79*log(N*N*(N*N))^44982398*N^50574343+N*N*log(N)^30945)*log((log(log(log(log((N)*N^68261717+N^55*N*(N))*(N*log(N*N)^434136131))^984970916+((N))*(N)*(N)*(log(N))+N+log(N)*log(N+N^32+log(N+(N))^551230789)^724093472)*(log(log((N+N+N*N*(log(N)^4686))*(N))^203362047+(N...

output:

25334 2077316115

result:

ok 2 tokens

Test #24:

score: -100
Wrong Answer
time: 1ms
memory: 4020kb

input:

log(log(log(log(log((log(log(log((N)*log(N+N)^221368132+N*N+log(log((N)+N+N)+N)^840025049+(N+N)))^348094141)*log(log(N+log(log(log(N)^2146522))*N+N*N))))*(N+N+(N+N^92+N+log(log(N)^8808+(N+(N^8275))+N^34251)^744192571+(log(N)^49*(N+N)+log(N*N)*N^15)+(N+N)*N*log(N*N+log((N*N)*N)*N+N*(N+N*N^6*N^1)))*lo...

output:

0 670936657

result:

wrong answer 2nd words differ - expected: '670936656', found: '670936657'