QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211658 | #360. Cultivation | Rafi22# | 0 | 0ms | 3624kb | C++14 | 1.7kb | 2023-10-12 20:03:18 | 2024-07-04 02:19:23 |
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});
}
if(sz(X)==0) return ;
R=(*X.begin()).st-1;
L=c-(*--X.end()).st;
int last=-1;
for(auto [Y,i]:X)
{
if(last!=-1) S=max(S,Y-last-1);
last=Y;
}
X.insert({-inf,0});
X.insert({inf,0});
sort(all(E));
for(auto [t,i]:E)
{
if(i<0) X.insert({y[-i],-i});
else
{
X.erase({y[i],i});
if(sz(X)==2) return ;
int LL=(*--X.upper_bound({y[i],0})).st;
int RR=(*X.upper_bound({y[i],0})).st;
if(LL==-inf) R=max(L,RR-1);
if(RR==inf) L=max(R,c-LL);
if(LL!=-inf&&RR!=inf) S=max(S,RR-LL-1);
}
}
if(U+D+max(S,R+L)==1)
{
cout<<U<<" "<<D<<endl;
}
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];
for(int i=0;i<=r;i++) for(int j=0;j<=r;j++) check(i,j);
cout<<ans;
return 0;
}
/*
3 3
3
1 2
1 3
3 3
*/
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 3484kb
input:
2 4 2 1 1 1 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
4 1 1 2 1
output:
3
result:
ok single line: '3'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
3 3 3 1 2 1 3 3 3
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 2 1 1 2
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
4 4 10 4 2 2 3 2 4 4 1 1 2 2 1 4 3 3 3 3 1 1 4
output:
2
result:
ok single line: '2'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4 4 1 4 1
output:
6
result:
ok single line: '6'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4 4 3 2 2 3 3 1 4
output:
5
result:
ok single line: '5'
Test #8:
score: -5
Wrong Answer
time: 0ms
memory: 3624kb
input:
4 4 15 4 3 2 4 4 4 4 1 3 3 1 2 3 1 2 1 3 4 3 2 4 2 2 3 1 3 2 2 1 4
output:
0 1 1 0 0
result:
wrong answer 1st lines differ - expected: '1', found: '0 1'
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%