제출 #247670

#제출 시각아이디문제언어결과실행 시간메모리
247670fivefourthreeone말 (IOI15_horses)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define owo(i,a, b) for(int i=(a); i<(b); ++i) #define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i) #define senpai push_back #define ttgl pair<int, int> #define ayaya cout<<"debug"<<endl using namespace std; using ll = long long; using ld = long double; const ll MOD = 1e9+7; const double PI = acos(-1); const int INF = 0x3f3f3f3f; const int NINF = 0x3f3f3f40; const ll INFLL = 0x3f3f3f3f3f3f3f3f; const ll NINFLL = 0x3f3f3f3f3f3f3f40; const int mxN = 500001; int n; set<int> good; int startpos = -1; int sgmax[2*mxN]; ll ans = 1; ll x[mxN], y[mxN]; void build() { for(int i=n; i<2*n; ++i) sgmax[i] = y[i-n]; for(int i=n-1; i>0; --i) sgmax[i] = max(sgmax[i<<1], sgmax[i<<1|1]); } void upd(int p, int val) { for(sgmax[p+=n] =val; p>0; p>>=1) sgmax[p>>1] = max(sgmax[p], sgmax[p^1]); } int qmax(int l, int r) { r++; int res = 0; for(l+=n, r+=n; l<r; l>>=1, r>>=1) { if(l&1)res = max(res, sgmax[l++]); if(r&1)res = max(res, sgmax[--r]); } return res; } ll binpow(ll a, ll b) { ll res = 1; while(b){ if(b&1) res = (res*a)%MOD; b>>=1; a = (a*a)%MOD;}return res;} ll modInv(ll x) {return binpow(x, MOD-2);} ll solve() { if(startpos==-1) return qmax(0, n-1); ll best= 1; ll curr = 1; ll partans = 1; int start = startpos; auto it = --good.end(); while(partans<1e9+7) { partans*=x[*it]; start = *it; if(it==good.begin())break; it--; } partans = 1; owo(i, startpos, start){ partans = partans*x[i]%MOD; } it = good.lower_bound(start); while(it!=good.end()) { curr = curr*(x[*it]); best = max(best, (ll)qmax(*it, next(it)==good.end() ? n-1 : *next(it))*curr); it++; } return ((ans*partans)%MOD*best%MOD); } ll init(int N, ll X[], ll Y[]) { n = N; owo(i, 0, mxN) { x[i] = X[i]; y[i] = Y[i]; } build(); owo(i, 0, n) { if(x[i]>1) good.insert(i); } auto it = --good.end(); int num = 60; while(num) { num--; if(it==good.begin())break; it--; } startpos = *it; owo(i, 0, startpos) { ans = (ans*x[i])%MOD; } return solve(); } ll updateX(int pos, int val) { if(x[pos]==1&&val!=1) { good.insert(pos); if(pos<startpos) { ans = (ans*val)%MOD; }else if(pos>startpos){ ans = (ans*x[startpos]%MOD); auto it = good.upper_bound(startpos); startpos = (it==good.end() ? -1 : *it); } }else if(x[pos]!=1&&val==1) { auto it = good.find(pos); if(pos<startpos) { ans = (ans*modInv(x[pos]))%MOD; }else if(pos>=startpos) { if(it!=good.begin()) { startpos = *prev(it); } } good.erase(good.find(pos)); } x[pos] = val; return solve(); } ll updateY(int pos, int val) { upd(pos, val); return solve(); } int main() { //freopen("filename.in", "r", stdin); //freopen("filename.out", "w", stdout); cin.tie(0)->sync_with_stdio(0); /*int tempn; ll tempx[mxN]; ll tempy[mxN]; cin>>tempn; owo(i, 0, tempn) { cin>>tempx[i]; } owo(i,0, tempn) { cin>>tempy[i]; } cout<<init(tempn, tempx, tempy);*/ return 0; }

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

horses.cpp: In function 'void build()':
horses.cpp:25:46: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
     for(int i=n; i<2*n; ++i) sgmax[i] = y[i-n];
                                         ~~~~~^
horses.cpp: In function 'll modInv(ll)':
horses.cpp:41:15: warning: declaration of 'x' shadows a global declaration [-Wshadow]
 ll modInv(ll x) {return binpow(x, MOD-2);}
               ^
horses.cpp:23:4: note: shadowed declaration is here
 ll x[mxN], y[mxN];
    ^
horses.cpp: In function 'll solve()':
horses.cpp:49:23: warning: conversion to 'double' from 'll {aka long long int}' may alter its value [-Wconversion]
     while(partans<1e9+7) {
                       ^
/tmp/ccmsZVi3.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccgEtyUe.o:horses.cpp:(.text.startup+0x0): first defined here
/tmp/ccmsZVi3.o: In function `main':
grader.c:(.text.startup+0x2db): undefined reference to `init(int, int*, int*)'
collect2: error: ld returned 1 exit status