QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211644#360. CultivationRafi22#0 1ms3560kbC++141.6kb2023-10-12 19:50:522024-07-04 02:19:21

Judging History

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

  • [2024-07-04 02:19:21]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3560kb
  • [2023-10-12 19:50:52]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
int inf=1000000007;
ll infl=1000000000000000007;
int mod=1000000007;
int mod1=998244353;

const int N=307;

int r,c,n;
int ans=inf;

int x[N],y[N];

void check(int U,int D)
{
    set<pair<int,int>>X;
    vector<pair<int,int>>E;
    int S=0,L=0,R=0;
    for(int i=1;i<=n;i++)
    {
        if(max(1,x[i]-D)==1) X.insert({y[i],i});
        else E.pb({max(1,x[i]-D),-i});
        if(min(r,x[i]+U)<r) E.pb({min(r,x[i]+U)+1,i});
      //  cout<<max(1,x[i]-D)<<" "<<min(r,x[i]+U)<<endl;
    }
    if(sz(X)==0) return ;
    R=(*X.begin()).st-1;
    L=c-(*--X.end()).st;
    X.insert({-inf,0});
    X.insert({inf,0});
    sort(all(E));
    for(auto [Y,i]:E)
    {
        if(i<0) X.insert({Y,-i});
        else
        {
            X.erase({Y,i});
            int LL=(*--X.upper_bound({Y,0})).st;
            if(LL==-inf) L=max(L,LL-1);
            int RR=(*X.upper_bound({Y,0})).st;
            if(RR==inf) R=max(R,c-RR);
            if(LL!=-inf&&RR!=inf) S=max(S,RR-LL);
        }
    }
    ans=min(ans,U+D+max(S,R+L));
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>r>>c>>n;
    for(int i=1;i<=n;i++) cin>>x[i]>>y[i];
   // check(1,1);
    for(int i=1;i<=r;i++) for(int j=1;j<=r;j++) check(i,j);
    cout<<ans;


    return 0;
}
/*
3 4
3
1 2
1 4
2 3
*/

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3560kb

input:

2 4
2
1 1
1 4

output:

2

result:

wrong answer 1st lines differ - expected: '3', found: '2'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #45:

score: 0
Time Limit Exceeded

input:

1000000000 1000000000
17
822413671 70423910
260075513 431043546
300945721 793553248
142848049 163787897
392462410 831950868
699005697 111397300
444396260 130450496
642691616 595456084
467968916 463598810
159764248 611476406
929313754 539645102
365153650 964108073
906780716 373514044
970118116 655138...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%