Submission #62297

# Submission time Handle Problem Language Result Execution time Memory
62297 2018-07-28T04:04:10 Z nvmdava Horses (IOI15_horses) C++17
Compilation error
0 ms 0 KB
#include "horses.h"
#include <bits/stdc++.h>

#define SIZE 500100;
#define INF 1<<30
#define MOD 1000000007


using namespace std;

long long mult[SIZE << 2];
int maxLoc[SIZE << 2];
long double lazy[SIZE << 2], A[SIZE], maxValue[SIZE << 2];
int X[SIZE], Y[SIZE], N;

void update2(int id, int l, int r, int k){
	if(l == k && r == k){
		mult[id] = X[l];
		return;
	}
	int m = (l + r) >> 1;
	if(m >=	k){
		update2(id << 1, l, m, k);
	} else {
		update2(id << 1 | 1,  m + 1, r, k);
	}
	
	mult[id] = muld[id << 1] * mult[id << 1 | 1] % MOD;
}

void update1(int id,int l, int r,int L,int R, long double diff){
	if(l == ql && r == qr){
		tree[id] += diff;
		lazy[id] += diff;
		return;
	}
	if(lazy[id] != 0){
		lazy[id << 1] +=lazy[id];
		lazy[id << 1 | 1] +=lazy[id];
		tree[id << 1] +=lazy[id];
		tree[id << 1 | 1] +=lazy[id];
		lazy[id] = 0;
	}
	int m = (l + r) >> 1;
	if(R <= m){
		update1(id << 1, l, m, L, R, diff);
	} else if(L > m){
		update1(id << 1 | 1,m + 1, r, L, R, diff);
	} else {
		update1(id << 1, l, m, L, R, diff);
		update1(id << 1 | 1,m + 1, r, L, R, diff);
	}
	if(maxValue[id << 1] > maxValue[id << 1 | 1]){
		maxValue[id] = maxValue[id << 1];
		maxLoc[id] = maxLoc[id << 1];
	} else { 
		maxValue[id] = maxValue[id << 1 | 1];
		maxLoc[id] = maxLoc[id << 1 | 1];
	}
}

long long solve(int id, int l, int r,int L,int R){
	if(L == l && r == R){
		return mult[id];
	}
	int m = (l + r) >> 1;
	if(R <= m){
		return solve( id << 2, l, m, L , R);
	} else if(L > m){
		return solve( id << 2 | 1, m + 1, r, L, R);
	}
	return solve( id << 2, l, m, L , R) * solve( id << 2 | 1, m + 1, r, L, R) % MOD;
}

void build(int id, int l, int r){
	if(l == r){
		maxLoc[id] = l;
		mult[id] = X[l];
		maxValue = A[l];
		return;
	}
	
	build(id << 1, l, (l + r) / 2);
	build(id << 1 | 1, (l + r) / 2 + 1, r);
	
	if(maxValue[id << 1] > maxValue[id << 1 | 1]){
		maxLoc[id] = maxLoc[id << 1];
		maxValue[id] = maxValue[id << 1];
	} else {
		maxLoc[id] = maxLoc[id << 1 | 1];
		maxValue[id] = maxValue[id << 1 | 1];
	}
	mult[id] = mult[id << 1] * mult[id << 1 | 1] % MOD;
}

int init(int n, int XX[], int YY[]) {
	N = n;
	for(int i = 1; i <= N ; i++){
		X[i] = XX[i - 1];
		Y[i] = YY[i - 1];
	}
	
	for(int i = 1; i <= N; i++){
		A[i] = A[i - 1] + log10(X[i]);
	}
	
	for(int i = 1; i <= N; i++){
		A[i] += log10[Y[i]];
	}
	
	build(1,1,N);
	return solve(1, 1, N , 1, maxLoc[1]) * Y[maxLoc[1]] % MOD;
}

int updateX(int pos, int val) {
	pos++;
    long double diff = log(val) - log(X[pos]);
    X[pos] = val;
    update1(1, 1, N, pos, N, diff);
    update2(1, 1, N, pos);
 
    return query2(1, 1, N, 1, maxValue[1]) * Y[maxValue[1]] % MOD;
	return 0;
}

int updateY(int pos, int val) {
	pos++;
	long double diff = log(val) - log(Y[pos]);
	Y[pos] = val;
	add(1,1,N,pos,pos,diff);
	
	return solve(1,1,N,1,maxLoc[1]) * Y[maxValue[1]] % MOD;
}

Compilation message

horses.cpp:4:20: error: expected ']' before ';' token
 #define SIZE 500100;
                    ^
horses.cpp:11:16: note: in expansion of macro 'SIZE'
 long long mult[SIZE << 2];
                ^~~~
horses.cpp:11:21: error: expected unqualified-id before '<<' token
 long long mult[SIZE << 2];
                     ^~
horses.cpp:4:20: error: expected ']' before ';' token
 #define SIZE 500100;
                    ^
horses.cpp:12:12: note: in expansion of macro 'SIZE'
 int maxLoc[SIZE << 2];
            ^~~~
horses.cpp:12:17: error: expected unqualified-id before '<<' token
 int maxLoc[SIZE << 2];
                 ^~
horses.cpp:4:20: error: expected ']' before ';' token
 #define SIZE 500100;
                    ^
horses.cpp:13:18: note: in expansion of macro 'SIZE'
 long double lazy[SIZE << 2], A[SIZE], maxValue[SIZE << 2];
                  ^~~~
horses.cpp:13:23: error: expected unqualified-id before '<<' token
 long double lazy[SIZE << 2], A[SIZE], maxValue[SIZE << 2];
                       ^~
horses.cpp:13:36: error: expected unqualified-id before ']' token
 long double lazy[SIZE << 2], A[SIZE], maxValue[SIZE << 2];
                                    ^
horses.cpp:13:53: error: expected unqualified-id before '<<' token
 long double lazy[SIZE << 2], A[SIZE], maxValue[SIZE << 2];
                                                     ^~
horses.cpp:4:20: error: expected ']' before ';' token
 #define SIZE 500100;
                    ^
horses.cpp:14:7: note: in expansion of macro 'SIZE'
 int X[SIZE], Y[SIZE], N;
       ^~~~
horses.cpp:14:11: error: expected unqualified-id before ']' token
 int X[SIZE], Y[SIZE], N;
           ^
horses.cpp:14:20: error: expected unqualified-id before ']' token
 int X[SIZE], Y[SIZE], N;
                    ^
horses.cpp: In function 'void update2(int, int, int, int)':
horses.cpp:18:3: error: 'mult' was not declared in this scope
   mult[id] = X[l];
   ^~~~
horses.cpp:18:14: error: 'X' was not declared in this scope
   mult[id] = X[l];
              ^
horses.cpp:28:2: error: 'mult' was not declared in this scope
  mult[id] = muld[id << 1] * mult[id << 1 | 1] % MOD;
  ^~~~
horses.cpp:28:13: error: 'muld' was not declared in this scope
  mult[id] = muld[id << 1] * mult[id << 1 | 1] % MOD;
             ^~~~
horses.cpp: In function 'void update1(int, int, int, int, int, long double)':
horses.cpp:32:10: error: 'ql' was not declared in this scope
  if(l == ql && r == qr){
          ^~
horses.cpp:32:10: note: suggested alternative: 'l'
  if(l == ql && r == qr){
          ^~
          l
horses.cpp:32:21: error: 'qr' was not declared in this scope
  if(l == ql && r == qr){
                     ^~
horses.cpp:32:21: note: suggested alternative: 'r'
  if(l == ql && r == qr){
                     ^~
                     r
horses.cpp:33:3: error: 'tree' was not declared in this scope
   tree[id] += diff;
   ^~~~
horses.cpp:33:3: note: suggested alternative: 'free'
   tree[id] += diff;
   ^~~~
   free
horses.cpp:34:3: error: 'lazy' was not declared in this scope
   lazy[id] += diff;
   ^~~~
horses.cpp:34:3: note: suggested alternative: 'labs'
   lazy[id] += diff;
   ^~~~
   labs
horses.cpp:37:5: error: 'lazy' was not declared in this scope
  if(lazy[id] != 0){
     ^~~~
horses.cpp:37:5: note: suggested alternative: 'labs'
  if(lazy[id] != 0){
     ^~~~
     labs
horses.cpp:40:3: error: 'tree' was not declared in this scope
   tree[id << 1] +=lazy[id];
   ^~~~
horses.cpp:40:3: note: suggested alternative: 'free'
   tree[id << 1] +=lazy[id];
   ^~~~
   free
horses.cpp:53:5: error: 'maxValue' was not declared in this scope
  if(maxValue[id << 1] > maxValue[id << 1 | 1]){
     ^~~~~~~~
horses.cpp:53:5: note: suggested alternative: 'si_value'
  if(maxValue[id << 1] > maxValue[id << 1 | 1]){
     ^~~~~~~~
     si_value
horses.cpp:55:3: error: 'maxLoc' was not declared in this scope
   maxLoc[id] = maxLoc[id << 1];
   ^~~~~~
horses.cpp:55:3: note: suggested alternative: 'malloc'
   maxLoc[id] = maxLoc[id << 1];
   ^~~~~~
   malloc
horses.cpp:58:3: error: 'maxLoc' was not declared in this scope
   maxLoc[id] = maxLoc[id << 1 | 1];
   ^~~~~~
horses.cpp:58:3: note: suggested alternative: 'malloc'
   maxLoc[id] = maxLoc[id << 1 | 1];
   ^~~~~~
   malloc
horses.cpp: In function 'long long int solve(int, int, int, int, int)':
horses.cpp:64:10: error: 'mult' was not declared in this scope
   return mult[id];
          ^~~~
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:77:3: error: 'maxLoc' was not declared in this scope
   maxLoc[id] = l;
   ^~~~~~
horses.cpp:77:3: note: suggested alternative: 'malloc'
   maxLoc[id] = l;
   ^~~~~~
   malloc
horses.cpp:78:3: error: 'mult' was not declared in this scope
   mult[id] = X[l];
   ^~~~
horses.cpp:78:14: error: 'X' was not declared in this scope
   mult[id] = X[l];
              ^
horses.cpp:79:3: error: 'maxValue' was not declared in this scope
   maxValue = A[l];
   ^~~~~~~~
horses.cpp:79:3: note: suggested alternative: 'si_value'
   maxValue = A[l];
   ^~~~~~~~
   si_value
horses.cpp:79:14: error: 'A' was not declared in this scope
   maxValue = A[l];
              ^
horses.cpp:86:5: error: 'maxValue' was not declared in this scope
  if(maxValue[id << 1] > maxValue[id << 1 | 1]){
     ^~~~~~~~
horses.cpp:86:5: note: suggested alternative: 'si_value'
  if(maxValue[id << 1] > maxValue[id << 1 | 1]){
     ^~~~~~~~
     si_value
horses.cpp:87:3: error: 'maxLoc' was not declared in this scope
   maxLoc[id] = maxLoc[id << 1];
   ^~~~~~
horses.cpp:87:3: note: suggested alternative: 'malloc'
   maxLoc[id] = maxLoc[id << 1];
   ^~~~~~
   malloc
horses.cpp:90:3: error: 'maxLoc' was not declared in this scope
   maxLoc[id] = maxLoc[id << 1 | 1];
   ^~~~~~
horses.cpp:90:3: note: suggested alternative: 'malloc'
   maxLoc[id] = maxLoc[id << 1 | 1];
   ^~~~~~
   malloc
horses.cpp:93:2: error: 'mult' was not declared in this scope
  mult[id] = mult[id << 1] * mult[id << 1 | 1] % MOD;
  ^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:97:2: error: 'N' was not declared in this scope
  N = n;
  ^
horses.cpp:99:3: error: 'X' was not declared in this scope
   X[i] = XX[i - 1];
   ^
horses.cpp:100:3: error: 'Y' was not declared in this scope
   Y[i] = YY[i - 1];
   ^
horses.cpp:104:3: error: 'A' was not declared in this scope
   A[i] = A[i - 1] + log10(X[i]);
   ^
horses.cpp:104:27: error: 'X' was not declared in this scope
   A[i] = A[i - 1] + log10(X[i]);
                           ^
horses.cpp:108:3: error: 'A' was not declared in this scope
   A[i] += log10[Y[i]];
   ^
horses.cpp:108:17: error: 'Y' was not declared in this scope
   A[i] += log10[Y[i]];
                 ^
horses.cpp:112:28: error: 'maxLoc' was not declared in this scope
  return solve(1, 1, N , 1, maxLoc[1]) * Y[maxLoc[1]] % MOD;
                            ^~~~~~
horses.cpp:112:28: note: suggested alternative: 'malloc'
  return solve(1, 1, N , 1, maxLoc[1]) * Y[maxLoc[1]] % MOD;
                            ^~~~~~
                            malloc
horses.cpp:112:41: error: 'Y' was not declared in this scope
  return solve(1, 1, N , 1, maxLoc[1]) * Y[maxLoc[1]] % MOD;
                                         ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:117:39: error: 'X' was not declared in this scope
     long double diff = log(val) - log(X[pos]);
                                       ^
horses.cpp:119:19: error: 'N' was not declared in this scope
     update1(1, 1, N, pos, N, diff);
                   ^
horses.cpp:122:31: error: 'maxValue' was not declared in this scope
     return query2(1, 1, N, 1, maxValue[1]) * Y[maxValue[1]] % MOD;
                               ^~~~~~~~
horses.cpp:122:31: note: suggested alternative: 'si_value'
     return query2(1, 1, N, 1, maxValue[1]) * Y[maxValue[1]] % MOD;
                               ^~~~~~~~
                               si_value
horses.cpp:122:12: error: 'query2' was not declared in this scope
     return query2(1, 1, N, 1, maxValue[1]) * Y[maxValue[1]] % MOD;
            ^~~~~~
horses.cpp:122:46: error: 'Y' was not declared in this scope
     return query2(1, 1, N, 1, maxValue[1]) * Y[maxValue[1]] % MOD;
                                              ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:128:36: error: 'Y' was not declared in this scope
  long double diff = log(val) - log(Y[pos]);
                                    ^
horses.cpp:130:10: error: 'N' was not declared in this scope
  add(1,1,N,pos,pos,diff);
          ^
horses.cpp:130:2: error: 'add' was not declared in this scope
  add(1,1,N,pos,pos,diff);
  ^~~
horses.cpp:130:2: note: suggested alternative: 'rand'
  add(1,1,N,pos,pos,diff);
  ^~~
  rand
horses.cpp:132:23: error: 'maxLoc' was not declared in this scope
  return solve(1,1,N,1,maxLoc[1]) * Y[maxValue[1]] % MOD;
                       ^~~~~~
horses.cpp:132:23: note: suggested alternative: 'malloc'
  return solve(1,1,N,1,maxLoc[1]) * Y[maxValue[1]] % MOD;
                       ^~~~~~
                       malloc
horses.cpp:132:38: error: 'maxValue' was not declared in this scope
  return solve(1,1,N,1,maxLoc[1]) * Y[maxValue[1]] % MOD;
                                      ^~~~~~~~
horses.cpp:132:38: note: suggested alternative: 'si_value'
  return solve(1,1,N,1,maxLoc[1]) * Y[maxValue[1]] % MOD;
                                      ^~~~~~~~
                                      si_value