제출 #139539

#제출 시각아이디문제언어결과실행 시간메모리
139539Plurm말 (IOI15_horses)C++11
0 / 100
625 ms61176 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; multimap<long double, int> mm; const int MOD = 1e9+7; int modpow(int base, int expo){ if(expo == 0) return 1; int res = modpow(base, expo/2); if(expo % 2 == 0){ return (1ll * res * res) % MOD; }else{ return 1ll * ((1ll * res * res) % MOD) * base % MOD; } } int invmod(int x){ return modpow(x, MOD-2); } long double FT1[500005]; int FT2[500005]; void add(int idx, int amt){ idx++; while(idx < 500005){ FT1[idx] += log2(amt); FT2[idx] = (1ll * FT2[idx] * amt) % MOD; idx += idx & -idx; } } long double sum1(int idx){ idx++; long double ret = 0; while(idx > 0){ ret += FT1[idx]; idx -= idx & -idx; } return ret; } int sum2(int idx){ idx++; int ret = 1; while(idx > 0){ ret = (1ll * ret * FT2[idx]) % MOD; idx -= idx & -idx; } return ret; } int rx[500005]; int ry[500005]; int init(int N, int X[], int Y[]) { for(int i = 0; i < N; i++){ rx[i] = X[i]; ry[i] = Y[i]; } for(int i = 0; i < N; i++){ add(i, X[i]); } for(int i = 0; i < N; i++){ mm.emplace(sum1(i) - log2l(Y[i]), sum2(i) * invmod(Y[i])); } return 0; } int answer(){ auto it = mm.rbegin(); return it->second; } int updateX(int pos, int val) { mm.erase(mm.find(sum1(pos) - log2l(ry[pos]))); add(pos, val - rx[pos]); rx[pos] = val; mm.emplace(sum1(pos) - log2l(ry[pos]), sum2(pos) * invmod(ry[pos])); return answer(); } int updateY(int pos, int val) { mm.erase(mm.find(sum1(pos) - log2l(ry[pos]))); ry[pos] = val; mm.emplace(sum1(pos) - log2l(ry[pos]), sum2(pos) * invmod(ry[pos])); return answer(); }

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

horses.cpp: In function 'int modpow(int, int)':
horses.cpp:11:34: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         return (1ll * res * res) % MOD;
                ~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:13:55: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         return 1ll * ((1ll * res * res) % MOD) * base % MOD;
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'void add(int, int)':
horses.cpp:25:43: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         FT2[idx] = (1ll * FT2[idx] * amt) % MOD;
                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int sum2(int)':
horses.cpp:42:38: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         ret = (1ll * ret * FT2[idx]) % MOD;
               ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
#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...