# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
93648 | ajmasin | Relativnost (COCI15_relativnost) | C++14 | 4021 ms | 27180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
const int maxn = 100100;
const int maxc = 25;
const int offset = (1<<17);
const int mod = 10007;
int n, c, q;
int niza[maxn];
int nizb[maxn];
inline int add(int a, int b)
{
a += b;
if(a >= mod) a -= mod;
if(a < 0) a += mod;
return a;
}
inline int mult(int a, int b)
{
return a * b % mod;
}
struct tournament
{
int brn[2 * offset][maxc];
void update(int cvor)
{
REP(i, 0, c + 1) brn[cvor][i] = 0;
REP(i, 0, c + 1)
{
REP(j, 0, c + 1)
{
int suma = i + j;
if(suma > c) suma = c;
brn[cvor][suma] = add(brn[cvor][suma], mult(brn[cvor * 2][i], brn[cvor * 2 + 1][j]));
}
}
return;
}
}T;
int main()
{
for(int i = 2 * offset - 1; i > 0; i--) T.brn[i][0] = 1;
scanf("%d%d", &n, &c);
int a, b;
REP(i, 0, n)
{
scanf("%d", &niza[i]);
niza[i] %= mod;
}
REP(i, 0, n)
{
scanf("%d", &nizb[i]);
nizb[i] %= mod;
}
REP(i, 0, n)
{
T.brn[i + offset][0] = nizb[i];
T.brn[i + offset][1] = niza[i];
int up = (i + offset) / 2;
while(up)
{
T.update(up);
up /= 2;
}
}
scanf("%d", &q);
int p;
REP(i, 0, q)
{
scanf("%d%d%d", &p, &a, &b);
a %= mod;
b %= mod;
p--;
T.brn[p + offset][0] = b;
T.brn[p + offset][1] = a;
p += offset;
p /= 2;
while(p)
{
T.update(p);
p /= 2;
}
printf("%d\n", T.brn[1][c]);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |