QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#61152#1833. DeletinglmeowdnRE 5ms13920kbC++171.8kb2022-11-10 20:32:262022-11-10 20:32:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-10 20:32:28]
  • 评测
  • 测评结果:RE
  • 用时:5ms
  • 内存:13920kb
  • [2022-11-10 20:32:26]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define eb emplace_back
#define y1 yylyylyylyyl
#define pc __builtin_popcount
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
 
long long read() {
    long long res=0, w=1; char c=getchar();
    while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
    while(isdigit(c)) {res=res*10+c-48, c=getchar();}
    return res*w;
}

const int N=4009;
int n,x[N],y[N],mx,cur;
int val[N][N];
bitset<4009>L[2][N],R[2][N];
bool fin;

void extend(int x,int y) {
    if(x==1&&y==n) {fin=1; return;}
    //cout<<x<<" "<<y<<" "<<R[0][x][y]<<endl;
    R[0][x][y]=0, R[1][x][y]=1;
    L[0][y][x]=0, L[1][y][x]=1;
    auto b=R[0][x]&R[1][y+1];
    for(int p=b._Find_first();p<=n;p=b._Find_next(p)) {
        if(!(R[0][x][p]&R[1][y+1][p])) continue;
        extend(x,p);
    }
    b=L[0][y]&L[1][x-1];
    for(int p=b._Find_first();p<=n;p=b._Find_next(p)) {
        if(!(L[0][y][p]&L[1][x-1][p])) continue;
        extend(p,y);
    }
    int l0=x-1, r0=y+1;
    while(l0>=1&&r0<=n) {
        if(val[l0][r0]<=cur&&!R[1][l0][r0]) extend(l0,r0), l0--, r0++;
        else break;
    }
}

signed main() {
    n=read();
    rep(i,1,n) for(int j=i+1;j<=n;j+=2) {
        int p=read();
        x[p]=i, y[p]=j;
        mx=max(mx,p);
        val[x[p]][y[p]]=p;
    }
    rep(i,1,n) rep(j,i+1,n) R[0][i][j]=1, L[0][j][i]=1;
    rep(p,1,mx) {
        cur=p;
        //cout<<"ADD "<<p<<" "<<x[p]<<" "<<y[p]<<endl;
        if(x[p]+1==y[p]||R[1][x[p]+1][y[p]-1]) {
            int l0=x[p], r0=y[p];
            extend(l0,r0);
        }
        if(fin) return printf("%lld\n",p), 0;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 7620kb

input:

2
1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 2ms
memory: 9800kb

input:

6
2 1 3
4 5
6 7
8
9

output:

6

result:

ok 1 number(s): "6"

Test #3:

score: 0
Accepted
time: 4ms
memory: 9724kb

input:

10
20 21 2 11 25
3 24 18 8
6 17 7 5
22 4 23
14 15 1
19 16
12 10
13
9

output:

14

result:

ok 1 number(s): "14"

Test #4:

score: 0
Accepted
time: 1ms
memory: 9880kb

input:

16
49 48 18 41 52 64 4 6
22 20 32 50 56 36 9
3 1 27 58 51 35 40
61 43 38 12 7 34
8 59 39 25 46 16
44 29 15 17 24
10 47 2 57 62
14 5 23 33
30 45 19 60
63 28 13
54 55 26
53 31
11 42
21
37

output:

30

result:

ok 1 number(s): "30"

Test #5:

score: 0
Accepted
time: 4ms
memory: 9672kb

input:

20
91 19 90 92 5 41 15 50 18 36
97 8 23 74 53 67 83 40 26
4 16 31 82 80 28 49 6 21
58 63 70 34 27 89 68 20
55 100 35 77 52 24 11 87
94 13 66 1 32 54 86
60 79 75 93 45 73 2
48 72 12 37 29 95
56 17 44 84 30 22
14 65 76 69 62
47 78 7 57 42
39 61 99 81
88 25 98 59
85 38 10
33 51 71
64 46
43 3
96
9

output:

54

result:

ok 1 number(s): "54"

Test #6:

score: 0
Accepted
time: 3ms
memory: 13920kb

input:

100
750 481 1065 911 1943 427 1633 45 1841 234 1376 1075 1603 1682 1581 1284 28 5 1567 1540 2409 1430 695 667 1246 392 1183 1090 594 1481 524 2023 354 778 584 827 1516 796 1675 1829 189 1688 706 1679 1483 1010 1209 1393 399 210
40 149 1040 351 1435 320 340 577 898 449 1896 224 2168 1456 1222 1216 19...

output:

1289

result:

ok 1 number(s): "1289"

Test #7:

score: 0
Accepted
time: 5ms
memory: 11992kb

input:

100
561 1112 852 529 2112 323 265 2038 1970 1681 556 2261 887 277 1171 553 1887 48 2432 266 1304 1764 853 2205 2320 1532 571 1870 193 544 1135 874 2132 1162 102 2179 2307 2068 1990 1111 2420 2077 1779 2000 1996 2297 1981 450 1091 992
140 2474 744 537 42 1051 1086 1685 1307 1282 2387 167 31 1179 301 ...

output:

1082

result:

ok 1 number(s): "1082"

Test #8:

score: -100
Runtime Error

input:

1000
168625 248587 13361 216812 183629 130592 94183 152417 64237 66548 133370 190254 121255 46138 62441 214340 158394 100935 199720 242242 28785 185956 49195 170727 64011 159665 14265 193684 148792 234339 35901 173675 21572 54311 108353 180276 8738 219185 221308 163715 86748 23949 144379 9144 66996 ...

output:


result: