# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
710552 | 2023-03-15T10:57:13 Z | ssense | 말 (IOI15_horses) | C++14 | 113 ms | 21936 KB |
#include <bits/stdc++.h> #include "horses.h" using namespace std; #define MOD 1000000007 int ng; vector<int> xg; vector<int> yg; long long pref = 1; int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {long long x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int init(int n, int* x, int* y) { ng = n; for(int i = 0; i < n; i++) { xg.push_back(x[i]); yg.push_back(y[i]); } for(int i = 0; i < ng-32; i++) { pref*=xg[i]; pref%=MOD; } int stop = 0; long long p = 1; for(int i = ng-1; i >= 0; i--) { p*=xg[i]; if(p > 1000000000) { stop = i; break; } } p = pref; for(int i = max(0, ng-32); i < stop; i++) { p*=xg[i]; p%=MOD; } long long mx = 0; long long p2 = 1; for(int i = stop; i < ng; i++) { p2*=xg[i]; if(mx < p2*yg[i]) { mx = p2*yg[i]; } } return (int)((mx*p)%MOD); } int updateX(int pos, int val) { if(pos < ng-32) { pref*=power(xg[pos], MOD-2, MOD); pref%=MOD; pref*=val; pref%=MOD; } xg[pos] = val; int stop = 0; long long p = 1; for(int i = ng-1; i >= 0; i--) { p*=xg[i]; if(p > 1000000000) { stop = i; break; } } p = pref; for(int i = max(0, ng-32); i < stop; i++) { p*=xg[i]; p%=MOD; } long long mx = 0; long long p2 = 1; for(int i = stop; i < ng; i++) { p2*=xg[i]; if(mx < p2*yg[i]) { mx = p2*yg[i]; } } mx%=MOD; return (int)((mx*p)%MOD); } int updateY(int pos, int val) { yg[pos] = val; int stop = 0; long long p = 1; for(int i = ng-1; i >= 0; i--) { p*=xg[i]; if(p > 1000000000) { stop = i; break; } } p = pref; for(int i = max(0, ng-32); i < stop; i++) { p*=xg[i]; p%=MOD; } long long mx = 0; long long p2 = 1; for(int i = stop; i < ng; i++) { p2*=xg[i]; if(mx < p2*yg[i]) { mx = p2*yg[i]; } } mx%=MOD; return (int)((mx*p)%MOD); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 304 KB | Output is correct |
5 | Correct | 1 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 296 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 296 KB | Output is correct |
15 | Correct | 1 ms | 300 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 300 KB | Output is correct |
18 | Correct | 1 ms | 296 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 296 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 300 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 300 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Incorrect | 1 ms | 340 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 11052 KB | Output is correct |
2 | Incorrect | 113 ms | 21936 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 304 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 1 ms | 300 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 300 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 224 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 296 KB | Output is correct |
23 | Incorrect | 1 ms | 340 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 1 ms | 300 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 300 KB | Output is correct |
14 | Correct | 1 ms | 300 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 300 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Incorrect | 1 ms | 340 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |