답안 #1092374

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092374 2024-09-24T00:20:44 Z vjudge1 비밀 (JOI14_secret) C++17
0 / 100
342 ms 12236 KB
#include <bits/stdc++.h>
#include "secret.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("popcnt")
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using ii = pair<int,int>;
using pll = pair<ll, ll>;
 
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
using vpll = vector<pll>;
using vlld = vector<lld>;
 
// #define endl '\n'
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
 
#define fore(i,l,r) for(auto i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(auto i=r; i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)
 
bool cmin(ll &a, ll b) { if(b<a){a=b;return 1;}return 0; }
bool cmax(ll &a, ll b) { if(b>a){a=b;return 1;}return 0; }
void valid(ll in) { cout<<((in)?"YES\n":"NO\n"); }
ll lcm(ll a, ll b) { return (a/gcd(a,b))*b; }
ll gauss(ll n) { return (n*(n+1))/2; }

const int N = 1001;
int n, a[N], pr[4*N][N], sf[4*N][N];

void build(int id, int l, int r) {
    if (l == r) return;
    int m = (l+r)/2;
    pr[id][m+1] = a[m+1];
    fore (i, m+2, r+1) pr[id][i] = Secret(pr[id][i-1], a[i]);
    sf[id][m] = a[m];
    forex (i, m-1, l) sf[id][i] = Secret(a[i], sf[id][i+1]);
    build(id*2, l, m);
    build(id*2+1, m+1, r);
}

void Init (int n, int A[]) {
    ::n = n;
    fo (i, n) a[i] = A[i];
    build(1, 0, n-1);
}

int Query(int i, int j) {
    if (i == j) return a[i];
    int l = 0, r = n-1, id = 1;
    while (1) {
        int m = (l+r)/2;
        if (i<=m && j>m) return Secret(sf[id][i], pr[id][j]);
        if (i<=m) r = m;
        if (i>m) l = m+1;
    }
}

Compilation message

secret.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("O3")
      | 
secret.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Incorrect 92 ms 6392 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 587620235.
2 Incorrect 80 ms 6484 KB Wrong Answer: Query(102, 157) - expected : 32612619, actual : 962726377.
3 Incorrect 86 ms 6480 KB Wrong Answer: Query(334, 369) - expected : 363022362, actual : 547672410.
4 Incorrect 308 ms 12236 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 846921768.
5 Incorrect 342 ms 12168 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 212882718.
6 Incorrect 305 ms 12112 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 423176097.
7 Correct 317 ms 12208 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 310 ms 12108 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 317 ms 12120 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 313 ms 12112 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1