답안 #708304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708304 2023-03-11T14:07:02 Z Alihan_8 말 (IOI15_horses) C++17
17 / 100
75 ms 15152 KB
#include <bits/stdc++.h>
#include "horses.h"
#define Flag false
// include <ext/pb_ds/assoc_container.hpp>
// include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
// define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define mpr make_pair
#define ln '\n'
void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
//#define int long long
typedef long long ll;
const ll Mod = 1e9+7, N = 5e5+1;
vector <ll> bit(N, 1);
vector <int> x, y;
ll bin_pow(int x, int y){
    ll res = 1;
    while ( y ){
        if ( y & 1 ) res = res*x%Mod;
        x = x*x%Mod;
        y >>= 1;
    }
    return res;
}
bool chmax(int &x, int y){
    bool flag = false;
    if ( x < y ){
        x = y; flag |= true;
    }
    return flag;
}
void upd(int i, ll val){
    for (; i < N; i += i&-i ) bit[i] = bit[i]*val%Mod;
}
ll get(int i){
    ll res = 1;
    for (; i > 0; i -= i&-i ) res = res*bit[i]%Mod;
    return res;
}
int F(){
    int n = (int)x.size(), it = 0, val = y[max(0, n-30)];
    for ( int i = max(1, n-29); i < n; i++ ){
        val /= x[i];
        if ( val < y[i] ) it = i, val = y[i];
    }
    ll res = y[it]*get(it+1)%Mod;
    return res;;
}
int init(int N, int X[], int Y[]){
	int n = N;
	x.resize(n), y.resize(n);
	for ( int i = 0; i < n; i++ ){
        x[i] = X[i], y[i] = Y[i];
        upd(i+1, x[i]);
	}
    return F();
}
int updateX(int pos, int val){
    upd(pos+1, bin_pow(x[pos], Mod-2));
    x[pos] = val;
    upd(pos+1, x[pos]);
	return F();
}
int updateY(int pos, int val){
    y[pos] = val;
	return F();
}
#if Flag
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;
    int X[n], Y[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) << ln;
    int q; cin >> q;
    while ( q-- ){
        int type, l, r; cin >> type >> l >> r;
        if ( type == 1 ) cout << updateX(l, r) << ln;
        else cout << updateY(l, r) << ln;
    }

    cout << '\n';
/*
3
2 1 3
3 4 1
1
2 1 2
answer: {8, 6}
*/
}
#endif

Compilation message

horses.cpp: In function 'll bin_pow(int, int)':
horses.cpp:19:23: warning: declaration of 'y' shadows a global declaration [-Wshadow]
   19 | ll bin_pow(int x, int y){
      |                   ~~~~^
horses.cpp:18:17: note: shadowed declaration is here
   18 | vector <int> x, y;
      |                 ^
horses.cpp:19:16: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   19 | ll bin_pow(int x, int y){
      |            ~~~~^
horses.cpp:18:14: note: shadowed declaration is here
   18 | vector <int> x, y;
      |              ^
horses.cpp: In function 'bool chmax(int&, int)':
horses.cpp:28:24: warning: declaration of 'y' shadows a global declaration [-Wshadow]
   28 | bool chmax(int &x, int y){
      |                    ~~~~^
horses.cpp:18:17: note: shadowed declaration is here
   18 | vector <int> x, y;
      |                 ^
horses.cpp:28:17: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   28 | bool chmax(int &x, int y){
      |            ~~~~~^
horses.cpp:18:14: note: shadowed declaration is here
   18 | vector <int> x, y;
      |              ^
horses.cpp: In function 'int F()':
horses.cpp:50:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   50 |     return res;;
      |            ^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:52:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   52 | int init(int N, int X[], int Y[]){
      |          ~~~~^
horses.cpp:16:23: note: shadowed declaration is here
   16 | const ll Mod = 1e9+7, N = 5e5+1;
      |                       ^
horses.cpp: In function 'void IO(std::string)':
horses.cpp:13:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:13:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4172 KB Output is correct
3 Correct 2 ms 4228 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4224 KB Output is correct
6 Correct 2 ms 4180 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 2 ms 4224 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 2 ms 4228 KB Output is correct
11 Correct 2 ms 4224 KB Output is correct
12 Correct 2 ms 4228 KB Output is correct
13 Correct 3 ms 4180 KB Output is correct
14 Correct 2 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 2 ms 4180 KB Output is correct
17 Correct 2 ms 4180 KB Output is correct
18 Correct 2 ms 4228 KB Output is correct
19 Correct 2 ms 4228 KB Output is correct
20 Correct 2 ms 4228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4224 KB Output is correct
5 Correct 2 ms 4228 KB Output is correct
6 Correct 2 ms 4232 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 2 ms 4124 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 2 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4224 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 2 ms 4224 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 2 ms 4180 KB Output is correct
17 Correct 2 ms 4180 KB Output is correct
18 Correct 2 ms 4180 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 2 ms 4224 KB Output is correct
21 Incorrect 3 ms 4228 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 15152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4228 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4232 KB Output is correct
6 Correct 2 ms 4180 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 2 ms 4228 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 3 ms 4224 KB Output is correct
11 Correct 2 ms 4224 KB Output is correct
12 Correct 3 ms 4180 KB Output is correct
13 Correct 3 ms 4124 KB Output is correct
14 Correct 2 ms 4180 KB Output is correct
15 Correct 2 ms 4224 KB Output is correct
16 Correct 2 ms 4224 KB Output is correct
17 Correct 2 ms 4180 KB Output is correct
18 Correct 2 ms 4180 KB Output is correct
19 Correct 3 ms 4220 KB Output is correct
20 Correct 2 ms 4224 KB Output is correct
21 Incorrect 2 ms 4180 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 2 ms 4228 KB Output is correct
5 Correct 2 ms 4228 KB Output is correct
6 Correct 3 ms 4220 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 3 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 3 ms 4228 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 2 ms 4180 KB Output is correct
15 Correct 3 ms 4180 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 2 ms 4228 KB Output is correct
18 Correct 2 ms 4228 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 2 ms 4180 KB Output is correct
21 Incorrect 2 ms 4180 KB Output isn't correct
22 Halted 0 ms 0 KB -