QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#844099#147. FloppyStarrykiller0 0ms0kbC++202.2kb2025-01-05 14:39:002025-01-05 14:39:08

Judging History

你现在查看的是最新测评结果

  • [2025-01-05 14:39:08]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2025-01-05 14:39:00]
  • 提交

floppy

// Homura Akemi a.k.a. Starrykiller (/user/235125)
// I love Madoka Kaname forever! 
#include <bits/stdc++.h>
#include "floppy.h"

using namespace std;
// void save_to_floppy(const string& bits) {
//     cout<<bits<<'\n';
// }


auto range(auto l, auto r) { return views::iota(l,r); }
auto rev=views::reverse;

_GLIBCXX_ALWAYS_INLINE void chmax(auto &a, auto b) { a=max(a,b); }
_GLIBCXX_ALWAYS_INLINE void chmin(auto &a, auto b) { a=min(a,b); }


void read_array(int subtask_id, const std::vector<int> &v) {
    string bits;
    vector<int> stk;
    for (auto i: range(0u,size(v))) {
        while (size(stk) && v[stk.back()]<v[i]) bits.push_back('0'), stk.pop_back();
        bits.push_back('1'); stk.push_back(i);
    }
    save_to_floppy(bits);
}

constexpr int MAXN=1e5+10;
int stk[MAXN], top, ls[MAXN], rs[MAXN], vis[MAXN];
vector<int> g[MAXN]; int f[MAXN][19], dep[MAXN];

void dfs(int u, int fa) {
    dep[u]=dep[f[u][0]=fa]+1;
    for (int i=1; f[u][i-1]; ++i)
        f[u][i]=f[f[u][i-1]][i-1];
    for (auto v: g[u]) dfs(v,u);
}

int LCA(int u, int v) {
    if (dep[u]<dep[v]) swap(u,v);
    for (int i=18; ~i; --i) if (dep[f[u][i]]>=dep[v]) u=f[u][i];
    if (u==v) return u;
    for (int i=18; ~i; --i) if (f[u][i]!=f[v][i]) u=f[u][i], v=f[v][i];
    return f[u][0];
}

std::vector<int> solve_queries(int subtask_id, 
    int n, const std::string &bits, 
    const std::vector<int> &a,
    const std::vector<int> &b) {
    fill(ls,ls+n,-1); fill(rs,rs+n,-1);
    auto it=begin(bits);
    for (auto i: range(0,n)) {
        int cur=top;
        while (it!=end(bits) && *it=='0') --cur;
        if (cur) rs[stk[cur]]=i;
        if (cur<top) ls[i]=stk[cur+1];
        stk[top=++cur]=i; ++it;
    }
    for (int i=0; i<n; ++i) {
        if (ls[i]!=-1) g[i+1].emplace_back(ls[i]+1), vis[ls[i]+1]=1;
        if (rs[i]!=-1) g[i+1].emplace_back(rs[i]+1), vis[rs[i]+1]=1;
    }
    int root=0;
    for (int i=1; i<=n; ++i) if (!vis[i]) root=i;
    dfs(root,0);
    vector<int> res;
    for (auto i: range(0u,size(a))) {
        res.push_back(LCA(a[i]+1,b[i]+1)-1);
    }
    return res;
}

// int main() {
//     int sid, n; cin>>sid>>n;
//     vector<int> a(n); for (auto &i: a) cin>>i; 
//     read_array(sid,a);
// }

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Program floppy Time Limit Exceeded

Test #1:

score: 0
Program floppy Time Limit Exceeded

input:

1
496 992
484 491 478 483 452 446 458 493 453 457 468 418 440 241 267 365 462 441 495 39 54 70 26 97 152 24 105 85 170 298 42 275 305 295 297 207 211 296 184 346 98 123 171 157 135 194 243 156 115 196 169 53 138 93 263 251 201 195 333 324 396 338 270 311 359 289 290 486 403 183 339 310 473 464 471 4...

output:

986
10110111001000110101101101010011000011010110010110110001011010011011010110000110101110001011100111011000001111000011000111010011010001110110001101100011011100010110110011101011000000111100010101100110000110110011011001100110100001111010011101100000110111011110000011110100001101101010011110010100...

input:


output:


result:


Subtask #2:

score: 0
Program floppy Time Limit Exceeded

Test #6:

score: 0
Program floppy Time Limit Exceeded

input:

2
9998 19996
941669562 945620824 923950848 951745929 487936934 545172907 544098433 249251812 620978276 575815248 584717207 588068187 353162497 679201670 592738155 438327774 762119945 576801563 408534366 592715009 525377786 603981493 -93758897 137509462 -38676966 -36724784 654920761 -595506762 -64538...

output:

19989
101100110111000110101100011100011100110011011010001110010101010111000111100011001110110011100000110110000110101100111101110000000110110011001011010101110100110011011100010100110110011100110001110000000001101110100110101110010111001111001000011010011110010010011011101001010011000111010110001111...

input:


output:


result:


Subtask #3:

score: 0
Program floppy Time Limit Exceeded

Test #11:

score: 0
Program floppy Time Limit Exceeded

input:

3
39995 79990
922975946 766568552 929754744 983095922 988967630 879723897 928174186 951250463 831467029 836738151 464712826 467214506 167661408 156498284 426000721 530835328 -35115993 -86200136 327603078 448684869 192895652 125768327 402822176 196767853 409109378 985776352 976681898 967347754 989156...

output:

79980
110010101101011011011100100111001011100110010000011100001011010110010011111000011011000110111011000110110100100110000111101010100110100011011011001100111101010100000011011100111001001110010011010110100011010101011001101101000011101001101011110111000000001011010000011011011010011101001000110111...

input:


output:


result: