QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#819566 | #3289. Homework | huaxiamengjin | WA | 316ms | 336492kb | C++14 | 3.6kb | 2024-12-18 16:26:31 | 2024-12-18 16:26:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m;
pair<int,int>a[1010],b[1010],aa[1010],bb[1010];
int f[440][440][440];
int used[1010];
int n1,n2;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>m;
int m1=m,m2=n-m;
for (int i=1;i<=m1;i++)
cin>>a[i].first>>a[i].second;
// sort(a+1,a+m1+1);
{
memset(used,0,sizeof(used));
for (int i=1;i<=400;i++){
int mn=1e9,xu=0;
for (int j=1;j<=m1;j++)
if(used[j]==0&&a[j].first<=i&&a[j].second>=i)
if(mn>a[j].second)mn=a[j].second,xu=j;
if(xu!=0)used[xu]=1,aa[++n1]=a[xu];
}
}
// for (int i=1;i<=n1;i++)
// cout<<aa[i].first<<"~~~"<<aa[i].second<<"\n";
for (int i=1;i<=m2;i++)
cin>>b[i].first>>b[i].second;
// sort(b+1,b+m2+1);
{
memset(used,0,sizeof(used));
for (int i=1;i<=400;i++){
int mn=1e9,xu=0;
for (int j=1;j<=m2;j++)
if(used[j]==0&&b[j].first<=i&&b[j].second>=i)
if(mn>b[j].second)mn=b[j].second,xu=j;
if(xu!=0)used[xu]=1,bb[++n2]=b[xu];
}
}
// for (int i=1;i<=n2;i++)
// cout<<bb[i].first<<"~~~"<<bb[i].second<<"\n";
memset(f,63,sizeof(f));
f[0][0][0]=0;
swap(m1,n1);swap(m2,n2);
// cout<<m1<<"!!!"<<m2<<"\n";
for (int i=1;i<=400;i++){
for (int j=1;j<=m1;j++)if(aa[j].first<=i&&aa[j].second>=i){
int mn=1e9;
for (int jj=j+1;jj<=m1;jj++)
if(aa[jj].first<=i&&aa[jj].second>=i)mn=min(mn,aa[jj].second);
if(mn<aa[j].second)continue;
for (int jj=j-1;jj>=0;jj--){
for (int k=0;k<=m2;k++)
f[i][j][k]=min(f[i-1][jj][k]+1,f[i][j][k]);
if(jj!=j&&aa[jj].first<=i&&aa[jj].second>=i)break;
}
}
for (int k=1;k<=m2;k++)if(bb[k].first<=i&&bb[k].second>=i){
int mn=1e9;
for (int kk=k+1;kk<=m2;kk++)
if(bb[kk].first<=i&&bb[kk].second>=i)mn=min(mn,bb[kk].second);
if(mn<bb[k].second)continue;
for (int kk=k-1;kk>=0;kk--){
for (int j=0;j<=m1;j++)
f[i][j][k]=min(f[i-1][j][kk]+1,f[i][j][k]);
if(kk!=k&&bb[kk].first<=i&&bb[kk].second>=i)break;
}
}
for (int j=0;j<=m1;j++)
for (int k=0;k<=m2;k++){
int jj=j+1;
while(jj<=m1&&aa[jj].second<i)jj++;
int kk=k+1;
while(kk<=m2&&bb[kk].second<i)kk++;
if ((jj>m1||aa[jj].first>i)||(kk>m2||bb[kk].first>i))
f[i][j][k]=min(f[i][j][k],f[i-1][j][k]);
}
// for (int j=0;j<=m1;j++)
// for (int k=0;k<=m2;k++)
// cout<<i<<"!!"<<j<<" "<<k<<" "<<f[i][j][k]<<"\n";
// for (int j=0;j<=m1;j++)
// for (int k=0;k<=m2;k++)
// f[i][j+1][k]=min(f[i][j+1][k],f[i][j][k]),
// f[i][j][k+1]=min(f[i][j][k+1],f[i][j][k]);
}
int ans=f[401][0][0];
for (int j=0;j<=m1;j++)
for (int k=0;k<=m2;k++)
// if(j==m1||k==m2)
ans=min(ans,f[400][j][k]);
swap(n1,m1);swap(n2,m2);
for (int i=1;i<=m2;i++)
a[++m1]=b[i];
int ans2=0;
memset(used,0,sizeof(used));
for (int i=1;i<=400;i++){
int mn=1e9,xu=0;
for (int j=1;j<=m1;j++)
if(used[j]==0&&a[j].first<=i&&a[j].second>=i)
if(mn>a[j].second)mn=a[j].second,xu=j;
if(xu!=0)used[xu]=1,ans2++;
}
// cout<<m1<<"!!!!"<<m2<<"\n";
cout<<ans2<<"\n"<<ans<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 304ms
memory: 336444kb
input:
400 194 37 38 31 32 49 51 43 45 44 45 29 47 3 50 37 39 37 45 34 48 25 43 49 51 22 51 36 38 19 30 50 51 18 48 17 27 31 32 37 39 50 51 30 31 354 354 355 355 350 353 359 360 352 352 369 372 361 377 386 386 357 359 365 368 354 360 351 351 350 350 369 386 363 368 396 396 388 390 370 373 371 382 351 353 3...
output:
381 189
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 305ms
memory: 336452kb
input:
400 195 47 49 28 50 39 49 26 45 46 50 24 38 45 50 26 34 14 47 45 47 45 48 34 36 19 35 43 50 19 49 10 12 46 47 35 44 46 49 17 38 37 45 45 47 21 41 36 48 364 366 398 398 391 391 357 357 353 353 351 351 373 375 357 357 358 358 389 396 385 386 376 383 386 387 392 392 395 396 386 394 361 364 392 394 376 ...
output:
378 190
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 304ms
memory: 336432kb
input:
400 194 8 14 40 42 28 35 10 49 37 43 36 49 26 40 5 12 31 36 33 44 3 7 6 9 46 48 46 48 32 42 37 44 37 37 26 50 45 45 37 43 33 43 31 44 50 51 5 17 38 43 356 358 398 399 380 381 383 384 353 356 389 392 391 393 352 357 372 373 378 379 376 380 358 359 387 392 369 370 374 378 393 394 389 395 354 360 376 3...
output:
387 191
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 302ms
memory: 336492kb
input:
400 195 46 47 19 20 14 14 18 51 21 46 49 49 48 49 45 46 24 26 49 51 46 49 6 30 24 25 45 47 47 48 41 50 27 28 36 39 18 19 2 45 45 46 47 48 24 51 16 20 45 47 11 43 379 381 370 370 391 393 373 375 395 398 383 388 376 379 379 384 371 380 394 398 375 385 390 398 379 380 356 357 397 398 393 393 383 389 35...
output:
382 189
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 285ms
memory: 336368kb
input:
400 201 50 51 3 45 48 49 50 51 10 26 47 49 47 50 39 41 40 43 3 35 47 49 51 51 15 22 29 43 30 34 5 45 47 51 11 45 12 35 20 36 49 51 29 51 41 44 22 27 15 41 16 36 373 382 370 399 361 366 379 385 370 398 374 382 378 385 359 367 397 398 371 378 362 366 376 380 361 367 384 396 391 394 378 384 392 395 375...
output:
388 196
result:
ok 2 lines
Test #6:
score: 0
Accepted
time: 316ms
memory: 336368kb
input:
400 197 21 22 44 47 24 26 22 24 15 17 26 27 17 19 28 31 46 47 13 14 10 12 36 38 17 20 17 20 14 19 20 22 44 49 10 11 37 39 4 6 29 30 381 391 358 358 363 364 363 367 366 366 391 398 378 379 367 368 353 354 359 382 386 386 355 355 359 362 354 354 377 389 359 365 397 398 366 367 391 394 371 374 382 384 ...
output:
386 191
result:
ok 2 lines
Test #7:
score: 0
Accepted
time: 288ms
memory: 336428kb
input:
400 204 39 43 37 43 20 22 6 7 40 46 33 51 20 26 38 47 18 19 45 50 40 42 44 48 38 41 44 46 38 44 5 10 16 51 35 44 27 29 42 47 45 48 38 47 40 47 44 48 39 47 4 10 392 396 363 390 393 395 353 398 390 396 393 394 386 399 351 378 363 368 392 392 381 383 363 387 389 395 392 395 394 396 390 394 354 379 391 ...
output:
374 193
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 295ms
memory: 336432kb
input:
400 198 44 51 48 51 20 39 45 50 2 51 46 49 33 45 33 37 31 33 3 5 26 51 12 34 46 47 14 49 46 51 18 19 16 19 25 39 50 51 49 50 38 38 31 35 47 49 47 49 31 34 356 376 396 397 379 398 391 395 376 386 352 394 385 393 391 392 357 381 373 392 378 395 395 396 364 386 392 392 397 398 367 372 393 393 389 399 3...
output:
376 194
result:
ok 2 lines
Test #9:
score: -100
Wrong Answer
time: 288ms
memory: 336352kb
input:
400 203 49 50 20 22 38 40 13 33 18 19 48 50 9 10 36 38 44 44 36 39 38 39 51 51 22 23 26 29 48 51 22 23 50 51 29 29 35 36 19 24 48 50 2 5 48 49 49 50 31 41 50 51 47 50 394 396 356 372 361 399 364 396 394 395 394 396 353 364 394 396 392 394 374 382 364 383 353 366 376 383 394 395 393 395 361 381 368 3...
output:
389 195
result:
wrong answer 2nd lines differ - expected: '194', found: '195'