0x3b800001's blog

By 0x3b800001, history, 2 months ago, In English

On the task Moondance, I got this problem to solve. I wrote this piece of code.

function solve(input: string) -> string {
    let as = [from a in input.split("\n") select string(a)];
    let ans: string[] = [];
    let t = int(as[0]);
    let p2 = [1];
    let q = 1;
    for (let i = 1; i <= 1000000; i += 1) {
        q = q * 2 % 1000000007;
        p2.push(q);
    }
    for (let i = 1; i <= t; i += 1) {
        let n = int(as[i]);
        let res = n + 1;
        if (n == 1) {
          res = 1;
        } else {
          res = res * p2[n - 2] % 1000000007;
        }
        ans.push("Case " + string(i) + ": " + string(res));
    }
    return ans.join("\n") + "\n";
}

After executing it, I found it always gets "[9,7] Execution cost exceeded". However, after I tried submitting it, it got Accepted.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it
»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Why are you Posting again?

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

On NEARCrowd itself code transpiles to JavaScript, but when you submit it, it transpiles to C++. Execution cost exceeds just because JS is relatively slow, it doesn't always means that code will give TL or ML in OJ.