답안 #396276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
396276 2021-04-29T16:22:31 Z Killer2501 비밀 (JOI14_secret) C++14
0 / 100
20000 ms 4428 KB
#include<bits/stdc++.h>
#include "secret.h"
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define task "hopscotch"
#define pii pair<ll, pll>
using namespace std;
using ll = long long;
const int  N = 1e3+55;
const ll mod = 998244353;
const ll base = 350;
const ll cs = 331;
ll m, n, t, k, a[N], ans, tong, b[N], c[N], d[N], P[N][12];
vector<ll> adj[N], kq;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}

ll findp(ll u, ll lab[])
{
    return lab[u] < 0 ? u : lab[u] = findp(lab[u], lab);
}
void hop(ll u, ll v, ll lab[])
{
    u = findp(u, lab);
    v = findp(v, lab);
    if(u == v)return;
    if(lab[u] > lab[v])swap(lab[u], lab[v]);
    lab[u] += lab[v];
    lab[v] = u;
}
void dfs(ll u, ll p)
{
    for(ll v : adj[u])
    {
        if(v == p)continue;

    }
}
void sol()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    for(int i = 1; i < n; i ++)
    {
        ll x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(m, 0);
    cin >> m;
    while(m -- > 0)
    {
        ll xi, ki;
        cin >> xi >> ki;
        xi = (xi + ans) % n + 1;
        ki = (ki + ans) % n;
    }
}
void build(int id, int l, int r)
{
    if(l + 1 >= r)
    {
        for(int i = l; i <= r; i ++)P[i][id] = b[i];
        return;
    }
    ll mid = (l + r)  / 2;
    P[mid][id] = b[mid];
    P[mid+1][id] = b[mid+1];
    for(int i = mid-1; i >= l; i --)P[i][id] = Secret(b[i], P[i+1][id]);
    for(int i = mid+2; i <= r; i ++)P[i][id] = Secret(b[i], P[i-1][id]);
    build(id+1, l, mid-1);
    build(id+1, mid+1, r);
}
int get(int id, int l, int r, int u, int v)
{
    ll mid = (l + r) / 2;
    if(u <= mid && mid <= v)return id;
    if(mid < u)return get(id+1, l, mid-1, u, v);
    else return get(id+1, mid+1, r, u, v);
}
void Init(int N, int A[])
{
    m = N;    
    for(int i = 0; i < m; i ++)b[i] = A[i];

    build(0, 0, m-1);
}
int Query(int l, int r)
{
    if(l == r)return b[l];
    int id = get(0, 0, m-1, l, r);
    return Secret(P[l][id], P[r][id]);
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20033 ms 2372 KB Time limit exceeded
2 Incorrect 141 ms 2372 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 131 ms 2416 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Execution timed out 20029 ms 4420 KB Time limit exceeded
5 Execution timed out 20064 ms 4428 KB Time limit exceeded
6 Execution timed out 20046 ms 4356 KB Time limit exceeded
7 Incorrect 492 ms 4384 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 496 ms 4428 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 492 ms 4376 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 500 ms 4336 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.