제출 #139548

#제출 시각아이디문제언어결과실행 시간메모리
139548Plurm말 (IOI15_horses)C++11
17 / 100
671 ms42636 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; multiset<int> mm; const int MOD = 1e9+7; 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 answer(){ return *mm.rbegin(); } 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 < 500005; i++) FT2[i] = 1; for(int i = 0; i < N; i++){ add(i, X[i]); } for(int i = 0; i < N; i++){ mm.emplace((int)((1ll * sum2(i) * ry[i]) % MOD)); } return answer(); } int updateX(int pos, int val) { mm.erase(mm.find((int)((1ll * sum2(pos) * ry[pos]) % MOD))); add(pos, val - rx[pos]); rx[pos] = val; mm.emplace((int)((1ll * sum2(pos) * ry[pos]) % MOD)); return answer(); } int updateY(int pos, int val) { mm.erase(mm.find((int)((1ll * sum2(pos) * ry[pos]) % MOD))); ry[pos] = val; mm.emplace((int)((1ll * sum2(pos) * ry[pos]) % MOD)); return answer(); }

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

horses.cpp: In function 'void add(int, int)':
horses.cpp:13: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:30: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...