답안 #1014922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014922 2024-07-05T17:51:18 Z MarwenElarbi 말 (IOI15_horses) C++17
0 / 100
147 ms 53592 KB
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
#define ll long long
#define pb push_back
#define se second
#define fi first
const int MOD=1e9+7;
const int nax=5e5+5;
struct horse{
    long long x,y,A;
    double X,Y,m;
};
horse segtree[nax*4];
int n;
void update(int pos,int l,int r,int idx,int x,int y){
    if(l>idx||r<idx) return;
    if(l==r){
        if(x){
            segtree[pos].X=log10(x);
            segtree[pos].x=x;
        }if(y){
            segtree[pos].Y=log10(y);
            segtree[pos].y=y;
        }
        segtree[pos].m=segtree[pos].X+segtree[pos].Y;
        segtree[pos].A=x*y%MOD;
        return;
    }
    int mid=(r+l)/2;
    update(pos*2+1,l,mid,idx,x,y);
    update(pos*2+2,mid+1,r,idx,x,y);
    if(segtree[pos*2+1].m<segtree[pos*2+2].m+segtree[pos*2+1].X){
        segtree[pos].m=segtree[pos*2+2].m+segtree[pos*2+1].X;
        segtree[pos].A=segtree[pos*2+2].A*segtree[pos*2+1].x%MOD;
    }else{
        segtree[pos].m=segtree[pos*2+1].m;
        segtree[pos].A=segtree[pos*2+1].A;
    }
}
int init(int N, int X[], int Y[]){
    n=N;
    for (int i = 0; i < N; ++i)
    {
        update(0,0,n-1,i,X[i],Y[i]);
    }
    return segtree[0].A;
}

int updateX(int pos, int val){
    update(0,0,n-1,pos,val,0);
    return segtree[0].A;
}

int updateY(int pos, int val) {
    update(0,0,n-1,pos,0,val);
    return segtree[0].A;
}

/*
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    int N; cin>>N;

    int *X = (int*)malloc(sizeof(int)*(unsigned int)N);
    int *Y = (int*)malloc(sizeof(int)*(unsigned int)N);

    for (int i = 0; i < N; i++) {
        cin>>X[i];
    }

    for (int i = 0; i < N; i++) {
        cin>>Y[i];
    }   

    cout <<init(N,X,Y)<<" ";

    int M; cin>>M;

    for (int i = 0; i < M; i++) {
        int type; cin>>type; 
        int pos; cin>>pos;
        int val; cin>>val; 

        if (type == 1) {
            cout <<updateX(pos,val)<<" ";
        } else if (type == 2) {
            cout <<updateY(pos,val)<<" ";
        }
    }

    return 0;
}*/

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:47:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   47 |     return segtree[0].A;
      |            ~~~~~~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:52:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   52 |     return segtree[0].A;
      |            ~~~~~~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:57:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   57 |     return segtree[0].A;
      |            ~~~~~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 147 ms 53592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -