답안 #787570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787570 2023-07-19T09:49:12 Z vnm06 말 (IOI15_horses) C++14
컴파일 오류
0 ms 0 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;

long long mod=1e9+7;
long long n;
long long a[500005];
set<long long> st;

long long ost[2000005];
long long tree[2000005];

void update(long long v, long long le, long long ri, long long idx, long long val)
{
    if(le==ri) {tree[v]=val; return;}
    long long mid=(le+ri)/2;
    if(idx<=mid) update(2*v, le, mid, idx, val);
    else update(2*v+1, mid+1, ri, idx, val);
    tree[v]=max(tree[2*v], tree[2*v+1]);
}
long long query(long long v, long long le, long long ri, long long be, long long en)
{
    if(en<be) return 0;
    if(le>en || ri<be) return 0;
    if(be<=le && ri<=en) return tree[v];
    long long mid=(le+ri)/2;
    return max(query(2*v, le, mid, be, en), query(2*v+1, mid+1, ri, be, en));
}

void update2(long long v, long long le, long long ri, long long idx, long long val)
{
    if(le==ri) {ost[v]=val; return;}
    long long mid=(le+ri)/2;
    if(idx<=mid) update2(2*v, le, mid, idx, val);
    else update2(2*v+1, mid+1, ri, idx, val);
    ost[v]=(ost[2*v]*ost[2*v+1])%mod;
}
long long query2(long long v, long long le, long long ri, long long be, long long en)
{
    if(en<be) return 1;
    if(le>en || ri<be) return 1;
    if(be<=le && ri<=en) return ost[v];
    long long mid=(le+ri)/2;
    return (query2(2*v, le, mid, be, en)*query2(2*v+1, mid+1, ri, be, en))%mod;
}


long long spc[50], cf[50], brt=0;

long long solve()
{
    brt=0;
    long long ccf=1;
    if(st.empty()) return query(1, 0, n-1, 0, n-1);
    set<long long>::iterator it=st.begin();
    while(it!=st.end())
    {
        spc[brt]=-(*it);
        cf[brt]=a[-(*it)];
        brt++;
        ccf*=a[-(*it)];
        it++;
        if(ccf>1e9) break;
    }
    reverse(spc, spc+brt);
    reverse(cf, cf+brt);
    long long ans=0, id=0;
    if(ccf<=1e9) ans=query(1, 0, n-1, 0, n-1);
    long long rc=1;
    for(long long i=0; i<brt; i++)
    {
        if(i || ccf<1e9) rc*=a[i];
        long long tz=query(1, 0, n-1, spc[i], n-1);
        if(ans<tz*rc) ans=tz*rc;
    }
    if(ccf<=1e9) return ans%mod;
    return ((ans%mod)*query2(1, 0, n-1, 0, spc[0]))%mod;
}


long long init(long long N, long long X[], long long Y[])
{
    n=N;
    for(long long i=0; i<n; i++)
    {
        update(1, 0, n-1, i, Y[i]);
        update2(1, 0, n-1, i, X[i]);
        a[i]=X[i];
        if(a[i]>1) st.insert(-i);
    }
	return solve();
}

long long updateX(long long pos, long long val)
{
    if(a[pos]==1 && val>1) st.insert(-pos);
    else if(a[pos]>1 && val==1) st.erase(-pos);
    a[pos]=val;
	return solve();
}

long long updateY(long long pos, long long val)
{
    update(1, 0, n-1, pos, val);
	return solve();
}

Compilation message

horses.cpp: In function 'long long int solve()':
horses.cpp:63:12: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   63 |         if(ccf>1e9) break;
      |            ^~~
horses.cpp:68:8: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   68 |     if(ccf<=1e9) ans=query(1, 0, n-1, 0, n-1);
      |        ^~~
horses.cpp:72:17: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   72 |         if(i || ccf<1e9) rc*=a[i];
      |                 ^~~
horses.cpp:76:8: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   76 |     if(ccf<=1e9) return ans%mod;
      |        ^~~
horses.cpp:67:22: warning: unused variable 'id' [-Wunused-variable]
   67 |     long long ans=0, id=0;
      |                      ^~
/usr/bin/ld: /tmp/ccuwx2cP.o: in function `main':
grader.c:(.text.startup+0xaa): undefined reference to `init(int, int*, int*)'
/usr/bin/ld: grader.c:(.text.startup+0x113): undefined reference to `updateX(int, int)'
/usr/bin/ld: grader.c:(.text.startup+0x16d): undefined reference to `updateY(int, int)'
collect2: error: ld returned 1 exit status