UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213815#2406. Thief Mastersstawalr104429ms83652kbC++111.5kb2024-11-13 20:25:002024-11-13 23:05:55

answer

#include<bits/stdc++.h>
using namespace std;
const int mn=1e3+5;
int a,b,n;
int c[mn][mn],d[mn][mn];
int st[mn][mn][10],ts[mn][mn][10];
int lt[mn],ans;
void i1()
{
    lt[1]=0;
    for(int i=2;i<=1e3;i++)
    {
        lt[i]=lt[i>>1]+1;
    }
}
void i2(int x)
{
    for(int i=1;i<=b;i++)
    {
        st[x][i][0]=ts[x][i][0]=c[x][i];
    }
    for(int i=1;i<10;i++)
    {
        for(int j=1;j<=b-(1<<i)+1;j++)
        {
            st[x][j][i]=max(st[x][j][i-1],st[x][j+(1<<(i-1))+1][i-1]);
            ts[x][j][i]=min(ts[x][j][i-1],ts[x][j+(1<<(i-1))+1][i-1]);
        }
        // for(int )
    }
}
int q1(int x,int l,int r)
{
    int lf=lt[r-l+1];
    return max(st[x][l][lf],st[x][r-(1<<lf)+1][lf]);
    // for(int i=1;i<=)
}
int q2(int x,int l,int r)
{
    int lf=lt[r-l+1];
    return min(ts[x][l][lf],ts[x][r-(1<<lf)+1][lf]);
    // for(int i=1;i<=)
}
int main()
{
    i1();
    scanf("%d%d%d",&a,&b,&n);
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
            scanf("%d",&c[i][j]);
        }
        i2(i);
    }
    ans=0x3f3f3f3f;
    for(int i=1;i<=a-n+1;i++)
    {
        for(int j=1;j<=b-n+1;j++)
        {
            int tx,ti;
            tx=0;
            ti=0x3f3f3f3f;
            for(int l=1;l<=n;l++)
            {
                tx=max(tx,q1(i+l-1,j,j+n-1));
                ti=min(ti,q2(i+l-1,j,j+n-1));
            }
            // cerr<<i<<" "<<j<<" "<<tx<<" "<<ti<<'\n';
            ans=min(ans,tx-ti);
        }
    }
    printf("%d",ans);
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 856ms
memory: 83644kb

input:

1000 1000 100
804544523 340648618 718292412 235345736 704741136 942776831 741228920 463473302 677289...

output:

998357605

result:

wrong answer 1st lines differ - expected: '998893495', found: '998357605'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

5 4 2
1 2 5 6
0 17 16 0
16 17 0 1
2 10 2 1
1 2 3 2

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 3160kb

input:

100 100 10
2 100001 200001 300001 400001 500001 600001 700001 800001 900001 1000001 1100001 1200001 ...

output:

1208999

result:

wrong answer 1st lines differ - expected: '908999', found: '1208999'

Test #4:

score: 0
Wrong Answer
time: 422ms
memory: 83644kb

input:

1000 1000 20
1 100001 200001 300001 400001 500001 600001 700001 800001 900001 1000001 1100001 120000...

output:

2301899

result:

wrong answer 1st lines differ - expected: '1901899', found: '2301899'

Test #5:

score: 0
Wrong Answer
time: 122ms
memory: 26652kb

input:

500 500 50
79289095 232165705 955620938 481434262 465576217 112035388 50089892 459799006 181906335 3...

output:

994988952

result:

wrong answer 1st lines differ - expected: '995944328', found: '994988952'

Test #6:

score: 0
Wrong Answer
time: 339ms
memory: 42432kb

input:

500 1000 80
499163842 331022295 940054497 684192083 248823911 842132608 629298697 398526298 98438040...

output:

997645707

result:

wrong answer 1st lines differ - expected: '998299092', found: '997645707'

Test #7:

score: 0
Wrong Answer
time: 751ms
memory: 83652kb

input:

1000 1000 80
102 134 429 251 299 109 264 669 727 296 112 550 270 270 544 660 131 546 968 219 113 678...

output:

997

result:

wrong answer 1st lines differ - expected: '998', found: '997'

Test #8:

score: 0
Wrong Answer
time: 304ms
memory: 26656kb

input:

500 500 100
65532583 920409544 753795976 989349545 818384831 778207112 425141881 853270293 542112588...

output:

998530090

result:

wrong answer 1st lines differ - expected: '999172505', found: '998530090'

Test #9:

score: 0
Wrong Answer
time: 742ms
memory: 42428kb

input:

500 1000 100
456896744 779471086 578349238 52507342 192194992 156396237 475084995 775765435 96617474...

output:

998351576

result:

wrong answer 1st lines differ - expected: '998801667', found: '998351576'

Test #10:

score: 0
Wrong Answer
time: 893ms
memory: 83648kb

input:

1000 1000 100
629053044 957239666 456746076 940194386 201529807 592062148 244394389 825620014 223976...

output:

998161560

result:

wrong answer 1st lines differ - expected: '998862873', found: '998161560'