제출 #649484

#제출 시각아이디문제언어결과실행 시간메모리
649484ToroTN말 (IOI15_horses)C++14
0 / 100
69 ms23244 KiB
#include<bits/stdc++.h> using namespace std; #include "horses.h" #define ll long long #define X first #define Y second ll n,x[500005],y[500005],md=1000000007,nw,fight; ll seg[2000005],val,str,ans,last; void build(ll tree,ll st,ll ed) { ll md=(st+ed)/2; if(st==ed) { seg[tree]=y[ed]; return; } build(2*tree,st,md); build(2*tree+1,md+1,ed); seg[tree]=max(seg[2*tree],seg[2*tree+1]); } void update(ll tree,ll st,ll ed,ll idx,ll val) { ll md=(st+ed)/2; if(st==ed) { seg[tree]=y[idx]; return; } if(idx<=md) { update(2*tree,st,md,idx,val); }else { update(2*tree+1,md+1,ed,idx,val); } seg[tree]=max(seg[2*tree],seg[2*tree+1]); } ll query(ll tree,ll st,ll ed,ll l,ll r) { ll md=(st+ed)/2; if(st>r||ed<l)return -1e9; if(st>=l&&ed<=r)return seg[tree]; return max(query(2*tree,st,md,l,r),query(2*tree+1,md+1,ed,l,r)); } set<ll> s; stack<pair<ll,ll> > stk; int init(int N, int X[], int Y[]) { n=N; for(int i=1;i<=n;i++) { x[i]=X[i-1]; y[i]=Y[i-1]; } build(1,1,n); /*for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { printf("%d %d %lld\n",i,j,query(1,1,n,i,j)); } }*/ for(int i=1;i<n;i++) { if(x[i]>1)s.insert(i); if(s.size()>20)s.erase(s.find(*s.begin())); } for(auto it=s.begin();it!=s.end();it++) { stk.push({*it,query(1,1,n,(*it)+1,n)}); } nw=n; str=y[n]; ans=str; while(!stk.empty()) { fight=stk.top().X; val=stk.top().Y; //printf("%lld %lld\n",fight,val); stk.pop(); if(str>1e9) { str=1e18; ans*=x[nw]; ans%=md; }else { if(val>str*x[nw]) { str=val; ans=val; }else { str*=x[nw]; ans*=x[nw]; ans%=md; } } if(y[fight]>str) { str=y[fight]; ans=y[fight]; } nw=fight; } if(str>1e9) { str=1e18; ans*=x[nw]; ans%=md; return ans; }else { last=seg[1]; if(last>str) { return last; }else { ans*=x[nw]; ans%=md; return ans; } } } int updateX(int pos, int val) { ++pos; return 0; } int updateY(int pos, int val) { ++pos; return 0; }

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

horses.cpp: In function 'void build(long long int, long long int, long long int)':
horses.cpp:11:5: warning: declaration of 'md' shadows a global declaration [-Wshadow]
   11 |  ll md=(st+ed)/2;
      |     ^~
horses.cpp:7:26: note: shadowed declaration is here
    7 | ll n,x[500005],y[500005],md=1000000007,nw,fight;
      |                          ^~
horses.cpp: In function 'void update(long long int, long long int, long long int, long long int, long long int)':
horses.cpp:21:43: warning: declaration of 'val' shadows a global declaration [-Wshadow]
   21 | void update(ll tree,ll st,ll ed,ll idx,ll val)
      |                                           ^
horses.cpp:8:17: note: shadowed declaration is here
    8 | ll seg[2000005],val,str,ans,last;
      |                 ^~~
horses.cpp:23:5: warning: declaration of 'md' shadows a global declaration [-Wshadow]
   23 |  ll md=(st+ed)/2;
      |     ^~
horses.cpp:7:26: note: shadowed declaration is here
    7 | ll n,x[500005],y[500005],md=1000000007,nw,fight;
      |                          ^~
horses.cpp: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)':
horses.cpp:40:5: warning: declaration of 'md' shadows a global declaration [-Wshadow]
   40 |  ll md=(st+ed)/2;
      |     ^~
horses.cpp:7:26: note: shadowed declaration is here
    7 | ll n,x[500005],y[500005],md=1000000007,nw,fight;
      |                          ^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:80:6: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   80 |   if(str>1e9)
      |      ^~~
horses.cpp:105:5: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
  105 |  if(str>1e9)
      |     ^~~
horses.cpp:110:10: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  110 |   return ans;
      |          ^~~
horses.cpp:116:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  116 |    return last;
      |           ^~~~
horses.cpp:121:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  121 |    return ans;
      |           ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:126:26: warning: declaration of 'val' shadows a global declaration [-Wshadow]
  126 | int updateX(int pos, int val) {
      |                      ~~~~^~~
horses.cpp:8:17: note: shadowed declaration is here
    8 | ll seg[2000005],val,str,ans,last;
      |                 ^~~
horses.cpp:126:26: warning: unused parameter 'val' [-Wunused-parameter]
  126 | int updateX(int pos, int val) {
      |                      ~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:131:26: warning: declaration of 'val' shadows a global declaration [-Wshadow]
  131 | int updateY(int pos, int val) {
      |                      ~~~~^~~
horses.cpp:8:17: note: shadowed declaration is here
    8 | ll seg[2000005],val,str,ans,last;
      |                 ^~~
horses.cpp:131:26: warning: unused parameter 'val' [-Wunused-parameter]
  131 | int updateY(int pos, int val) {
      |                      ~~~~^~~
#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...