제출 #65749

#제출 시각아이디문제언어결과실행 시간메모리
65749Hoget157Horses (IOI15_horses)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define long long ll
#define MOD 1000000007
using namespace std;

ll n;

class RMQ{
	ll seg,ini;
	vector<ll> dat;
	function<ll(ll,ll)> f;
	public:
	RMQ() : seg(1){}
	void init(ll def,function<ll(ll,ll)> F){
		ini = def;
		f = F;
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(ll i = 0;i < seg * 2 - 1;i++) dat[i] = ini;
	}
	void update(ll i,ll x){
		i += seg - 1;
		dat[i] = x;
		while(i){
			i = (i - 1) / 2;
			dat[i] = f(dat[i * 2 + 1],dat[i * 2 + 2]);
		}
	}
	ll get(ll a,ll b,ll k = 0,ll l = 0,ll r = -1){
		if(r == -1) r = seg;
		if(b <= l || r <= a) return ini;
		if(a <= l && r <= b) return dat[k];
		return f(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r));
	}
	ll find(ll a,ll b,bool isl,ll k = 0,ll l = 0,ll r = -1){
		if(b == -1) b = seg;
		if(r == -1) r = seg;
		if(dat[k] == 1 || b <= l || r <= a) return -1;
		if(r - l == 1) return l;
		ll lans = find(a,b,isl,k * 2 + 1,l,(l + r) / 2),rans = find(a,b,isl,k * 2 + 2,(l + r) / 2,r);
		if(isl){
			if(lans != -1) return lans;
			return rans;
		}else{
			if(rans != -1) return rans;
			return lans;
		}
	}
};

RMQ rmq1,rmq2,seki;

ll calc(){
	ll pos = n - 1,tmp = 1,ma = 0,ans;
	while(pos > 0){
		pos = rmq1.find(0,pos,false);
		if(tmp * rmq1.get(pos,pos + 1) > 1000000000) break;
	}
	ans = seki.get(0,pos + 1);
	tmp = 1;
	while(pos < n - 1){
		ll nxt = rmq1.find(pos + 1,-1,true);
		ma = max(ma,tmp * rmq2.get(pos,nxt));
		tmp *= rmq1.get(nxt,nxt + 1);
		pos = nxt;
	}
	return ma * ans % MOD;
}

ll init(int N,int x[],int y[]){
	n = N + 2;
	rmq1.init(0,[](ll a,ll b){ return max(a,b); });
	rmq2.init(0,[](ll a,ll b){ return max(a,b); });
	seki.init(1,[](ll a,ll b){ return a * b % MOD; });
	rmq1.update(0,MOD);
	rmq1.update(n - 1,MOD);
	for(ll i = 0;i < n - 2;i++){
		rmq1.update(i + 1,x[i]);
		rmq2.update(i + 1,y[i]);
		seki.update(i + 1,x[i]);
	}
	return calc();
}

ll updateX(int pos,int val){
	rmq1.update(pos + 1,val);
	seki.update(pos + 1,val);
	return calc();
}

ll updateY(int pos,int val){
	rmq2.update(pos + 1,val);
	return calc();
}

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp:6:1: error: 'll' does not name a type
 ll n;
 ^~
horses.cpp:9:2: error: 'll' does not name a type
  ll seg,ini;
  ^~
horses.cpp:10:9: error: 'll' was not declared in this scope
  vector<ll> dat;
         ^~
horses.cpp:10:11: error: template argument 1 is invalid
  vector<ll> dat;
           ^
horses.cpp:10:11: error: template argument 2 is invalid
horses.cpp:11:14: error: 'll' was not declared in this scope
  function<ll(ll,ll)> f;
              ^~
horses.cpp:11:17: error: 'll' was not declared in this scope
  function<ll(ll,ll)> f;
                 ^~
horses.cpp:11:11: error: 'll' was not declared in this scope
  function<ll(ll,ll)> f;
           ^~
horses.cpp:11:20: error: template argument 1 is invalid
  function<ll(ll,ll)> f;
                    ^
horses.cpp:14:12: error: 'll' has not been declared
  void init(ll def,function<ll(ll,ll)> F){
            ^~
horses.cpp:14:31: error: 'll' was not declared in this scope
  void init(ll def,function<ll(ll,ll)> F){
                               ^~
horses.cpp:14:34: error: 'll' was not declared in this scope
  void init(ll def,function<ll(ll,ll)> F){
                                  ^~
horses.cpp:14:28: error: 'll' was not declared in this scope
  void init(ll def,function<ll(ll,ll)> F){
                            ^~
horses.cpp:14:37: error: template argument 1 is invalid
  void init(ll def,function<ll(ll,ll)> F){
                                     ^
horses.cpp:21:14: error: 'll' has not been declared
  void update(ll i,ll x){
              ^~
horses.cpp:21:19: error: 'll' has not been declared
  void update(ll i,ll x){
                   ^~
horses.cpp:29:2: error: 'll' does not name a type
  ll get(ll a,ll b,ll k = 0,ll l = 0,ll r = -1){
  ^~
horses.cpp:35:2: error: 'll' does not name a type
  ll find(ll a,ll b,bool isl,ll k = 0,ll l = 0,ll r = -1){
  ^~
horses.cpp: In constructor 'RMQ::RMQ()':
horses.cpp:13:10: error: class 'RMQ' does not have any field named 'seg'
  RMQ() : seg(1){}
          ^~~
horses.cpp: In member function 'void RMQ::init(int, int)':
horses.cpp:15:3: error: 'ini' was not declared in this scope
   ini = def;
   ^~~
horses.cpp:15:3: note: suggested alternative: 'init'
   ini = def;
   ^~~
   init
horses.cpp:17:9: error: 'seg' was not declared in this scope
   while(seg < n) seg *= 2;
         ^~~
horses.cpp:17:15: error: 'n' was not declared in this scope
   while(seg < n) seg *= 2;
               ^
horses.cpp:17:15: note: suggested alternative: 'yn'
   while(seg < n) seg *= 2;
               ^
               yn
horses.cpp:18:7: error: request for member 'resize' in '((RMQ*)this)->RMQ::dat', which is of non-class type 'int'
   dat.resize(seg * 2 - 1);
       ^~~~~~
horses.cpp:18:14: error: 'seg' was not declared in this scope
   dat.resize(seg * 2 - 1);
              ^~~
horses.cpp:19:7: error: 'll' was not declared in this scope
   for(ll i = 0;i < seg * 2 - 1;i++) dat[i] = ini;
       ^~
horses.cpp:19:16: error: 'i' was not declared in this scope
   for(ll i = 0;i < seg * 2 - 1;i++) dat[i] = ini;
                ^
horses.cpp: In member function 'void RMQ::update(int, int)':
horses.cpp:22:8: error: 'seg' was not declared in this scope
   i += seg - 1;
        ^~~
horses.cpp:23:8: error: invalid types 'int[int]' for array subscript
   dat[i] = x;
        ^
horses.cpp:26:9: error: invalid types 'int[int]' for array subscript
    dat[i] = f(dat[i * 2 + 1],dat[i * 2 + 2]);
         ^
horses.cpp:26:28: error: invalid types 'int[int]' for array subscript
    dat[i] = f(dat[i * 2 + 1],dat[i * 2 + 2]);
                            ^
horses.cpp:26:43: error: invalid types 'int[int]' for array subscript
    dat[i] = f(dat[i * 2 + 1],dat[i * 2 + 2]);
                                           ^
horses.cpp:26:44: error: expression cannot be used as a function
    dat[i] = f(dat[i * 2 + 1],dat[i * 2 + 2]);
                                            ^
horses.cpp: At global scope:
horses.cpp:53:1: error: 'll' does not name a type
 ll calc(){
 ^~
horses.cpp:70:1: error: 'll' does not name a type
 ll init(int N,int x[],int y[]){
 ^~
horses.cpp:85:1: error: 'll' does not name a type
 ll updateX(int pos,int val){
 ^~
horses.cpp:91:1: error: 'll' does not name a type
 ll updateY(int pos,int val){
 ^~