답안 #225769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225769 2020-04-21T14:20:12 Z staniewzki 말 (IOI15_horses) C++17
100 / 100
254 ms 42488 KB
#include<bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
 
#include "horses.h"

struct Node {
	int x, y;
	double _x, _y;
};

const int mod = int(1e9 + 7);
int mul(int a, int b) {
	return (long long) a * b % mod;
}

Node operator+(Node &a, Node &b) {
	Node ret;
	if(a._y > a._x + b._y) {
		ret.y = a.y;
		ret._y = a._y;
	}
	else {
		ret.y = mul(a.x, b.y);
		ret._y = a._x + b._y;
	}

	ret.x = mul(a.x, b.x);
	ret._x = a._x + b._x;
	return ret;
};

struct Tree {
	vector<Node> tree;
	int sz = 1;

	Tree(int n = 0) {
		while(sz < n) sz *= 2;
		tree.resize(sz * 2);
	}

	void update(int pos) {
		pos += sz;
		tree[pos]._x = log2(tree[pos].x);
		tree[pos]._y = log2(tree[pos].y);
		while(pos /= 2)
			tree[pos] = tree[pos * 2] + tree[pos * 2 + 1];
	}

	Node& operator[](int pos) { return tree[pos + sz]; }
	int query() { return tree[1].y; }
} tree;

int init(int N, int X[], int Y[]) {
	tree = Tree(N + 1);
	REP(i, N) {
		tree[i].x = X[i];
		tree[i + 1].y = Y[i];
	}
	REP(i, N + 1) tree.update(i);
	return tree.query();
}

int updateX(int pos, int val) {	
	tree[pos].x = val;
	tree.update(pos);
	return tree.query();
}

int updateY(int pos, int val) {
	tree[++pos].y = val;
	tree.update(pos);
	return tree.query();
}

Compilation message

horses.cpp: In function 'int mul(int, int)':
horses.cpp:15:27: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return (long long) a * b % mod;
         ~~~~~~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 30968 KB Output is correct
2 Correct 254 ms 42468 KB Output is correct
3 Correct 179 ms 33656 KB Output is correct
4 Correct 219 ms 37496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 432 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 6 ms 256 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 7 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 256 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 136 ms 32888 KB Output is correct
34 Correct 140 ms 32888 KB Output is correct
35 Correct 175 ms 39800 KB Output is correct
36 Correct 172 ms 39800 KB Output is correct
37 Correct 127 ms 31020 KB Output is correct
38 Correct 152 ms 31992 KB Output is correct
39 Correct 121 ms 30976 KB Output is correct
40 Correct 158 ms 34808 KB Output is correct
41 Correct 123 ms 30968 KB Output is correct
42 Correct 122 ms 31096 KB Output is correct
43 Correct 149 ms 35192 KB Output is correct
44 Correct 154 ms 35192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 364 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 166 ms 33656 KB Output is correct
34 Correct 237 ms 42488 KB Output is correct
35 Correct 197 ms 33656 KB Output is correct
36 Correct 229 ms 37496 KB Output is correct
37 Correct 138 ms 32888 KB Output is correct
38 Correct 146 ms 32888 KB Output is correct
39 Correct 175 ms 39800 KB Output is correct
40 Correct 170 ms 39800 KB Output is correct
41 Correct 128 ms 31096 KB Output is correct
42 Correct 157 ms 31992 KB Output is correct
43 Correct 124 ms 30976 KB Output is correct
44 Correct 151 ms 34936 KB Output is correct
45 Correct 130 ms 30976 KB Output is correct
46 Correct 128 ms 31096 KB Output is correct
47 Correct 147 ms 35192 KB Output is correct
48 Correct 148 ms 35192 KB Output is correct
49 Correct 203 ms 34936 KB Output is correct
50 Correct 200 ms 34936 KB Output is correct
51 Correct 203 ms 41848 KB Output is correct
52 Correct 204 ms 41184 KB Output is correct
53 Correct 181 ms 33252 KB Output is correct
54 Correct 186 ms 33912 KB Output is correct
55 Correct 163 ms 31968 KB Output is correct
56 Correct 180 ms 36632 KB Output is correct
57 Correct 152 ms 32636 KB Output is correct
58 Correct 159 ms 33276 KB Output is correct
59 Correct 147 ms 35320 KB Output is correct