제출 #340259

#제출 시각아이디문제언어결과실행 시간메모리
340259AmineWeslati말 (IOI15_horses)C++14
0 / 100
1158 ms73452 KiB
//Never stop trying
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
#include "bits/stdc++.h"
#ifndef LOCAL
#include "horses.h"
#endif
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef string str;
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 5e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
//constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

ll random(ll a, ll b){
    return a + rng() % (b - a + 1);
}

#ifndef LOCAL  
#define cerr if(false) cerr
#endif
#define dbg(x) cerr << #x << " : " << x << endl; 
#define dbgs(x,y) cerr << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << #v << " : " << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;
#define here() cerr << "here" << endl;

void IO() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int modpow(int x, int p){
	if(p==0) return 1;
	ll v=modpow(x,p/2);
	v*=v; v%=MOD;
	if(p&1) v*=x,v%=MOD;
	return v; 
}
int cnvrt(ld x){
	int v=x;
	ll ans=modpow(10,v);
	ans*=(int)(pow(10,(ld)(x-v))+0.5);
	ans%=MOD;
	return ans;
}

int N,X[MX],Y[MX];

struct node{
	ld lazy=0,mx=0;
};

V<node> t(MX*4);

void push_down(int pos){
	t[pos*2].lazy+=t[pos].lazy;
	t[pos*2+1].lazy+=t[pos].lazy;
	t[pos*2].mx+=t[pos].lazy;
	t[pos*2+1].mx+=t[pos].lazy;
	t[pos].lazy=0;
}
void upd(int l, int r, ld val, int pos=1, int tl=0, int tr=N-1){
	if(l>r) return;
	if(l==tl && r==tr){
		t[pos].mx+=val;
		t[pos].lazy+=val;
		return;
	}
	push_down(pos);
	int tm=(tl+tr)/2;
	upd(l,min(r,tm),val,pos*2,tl,tm);
	upd(max(l,tm+1),r,val,pos*2+1,tm+1,tr);
	t[pos].mx=max(t[pos*2].mx,t[pos*2+1].mx);
}

int init(int NN, int XX[], int YY[]) {
	N=NN; FOR(i,0,N) X[i]=XX[i],Y[i]=YY[i];
	FOR(i,0,N){
		upd(i,N-1,log10(X[i]));
		upd(i,i,log10(Y[i]));
	}
	return cnvrt(t[1].mx);
}

int updateX(int pos, int val) {	
	upd(pos,N-1,log10(val)-log10(X[pos]));
	X[pos]=val;
	return cnvrt(t[1].mx);
}

int updateY(int pos, int val) {
	upd(pos,pos,log10(val)-log10(Y[pos]));
	Y[pos]=val;
	return cnvrt(t[1].mx);
}

#ifdef LOCAL
int main() {
    boost; IO();

    int N; cin>>N;
    int x[N],y[N]; 
    FOR(i,0,N) cin>>x[i];
    FOR(i,0,N) cin>>y[i];
    cout << init(N,x,y) << endl;

    cout << updateY(1,2) << endl;

    

    return 0;
}
#endif

/* Careful!!!
    .Array bounds
    .Infinite loops
    .Uninitialized variables / empty containers
    .Multisets are shit

   Some insights:
    .Binary search
    .Graph representation
    .Write brute force code
    .Change your approach
*/

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

horses.cpp: In function 'int modpow(int, int)':
horses.cpp:73:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   73 |  return v;
      |         ^
horses.cpp: In function 'int cnvrt(ld)':
horses.cpp:76:8: warning: conversion from 'ld' {aka 'long double'} to 'int' may change value [-Wfloat-conversion]
   76 |  int v=x;
      |        ^
horses.cpp:80:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   80 |  return ans;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...