ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212047 | #3816. 元素 | OS_AC | 0 | 154ms | 1228kb | C++ | 961b | 2024-10-13 10:39:58 | 2024-10-13 12:17:05 |
answer
#include<bits/stdc++.h>
using namespace std;
void cleancin_n(){
cin.ignore(numeric_limits<streamsize>::max(),'\n');
}
int a[1000001];
bool mp[10001]={0};
int check(int L,int R,int x,int y){
memset(mp,false,sizeof(mp));
for(int i=L;i<=R;i++){
mp[a[i]]=true;
}
for(int i=x;i<=y;i++){
mp[a[i]]=false;
}
for(int i=1;i<=10001;i++){
if(mp[i]==true){
return false;
}
}
return true;
}
int getans(int L,int R){
int minn=INT_MAX-1;
for(int x=L;x<=R;x++){
for(int y=x;y<=R;y++){
cout<<x<<" "<<y<<" "<<check(L,R,x,y)<<endl;
if(check(L,R,x,y)){
minn=min(minn,y-x+1);
cout<<minn<<endl;
}
}
}
return (minn==INT_MAX-1)?-1:minn;
}
int l[10001],r[10001];
signed main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=q;i++){
cin>>l[i]>>r[i];
}
for(int i=1;i<=q;i++){
cout<<l[i]<<" "<<r[i]<<endl;
cout<<getans(l[i],r[i])<<endl;
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 1220kb
input:
10 10 492 1887 1028 1209 252 1860 1527 699 1656 928 6 9 2 8 3 10 2 3 1 8 6 9 3 5 4 7 1 4 2 7
output:
6 9 6 6 0 6 7 0 6 8 0 6 9 0 7 7 0 7 8 0 7 9 0 8 8 0 8 9 0 9 9 0 -1 2 8 2 2 0 2 3 0 2 4 0 2 5 0 2 6 0...
result:
wrong answer 1st numbers differ - expected: '4', found: '6'
Test #2:
score: 0
Wrong Answer
time: 43ms
memory: 1224kb
input:
50 50 413 1208 1780 279 1403 1706 11 1583 333 355 1068 1270 1835 1042 957 423 1140 1153 1709 284 281...
output:
35 44 35 35 0 35 36 0 35 37 0 35 38 0 35 39 0 35 40 0 35 41 0 35 42 0 35 43 0 35 44 0 36 36 0 36 37 ...
result:
wrong answer 1st numbers differ - expected: '10', found: '35'
Test #3:
score: 0
Wrong Answer
time: 20ms
memory: 1228kb
input:
50 50 407 1089 1459 1626 1917 555 1611 492 443 1149 406 1259 1729 1554 577 1310 1899 1578 1005 1459 ...
output:
2 33 2 2 0 2 3 0 2 4 0 2 5 0 2 6 0 2 7 0 2 8 0 2 9 0 2 10 0 2 11 0 2 12 0 2 13 0 2 14 0 2 15 0 2 16 ...
result:
wrong answer 1st numbers differ - expected: '32', found: '2'
Test #4:
score: 0
Wrong Answer
time: 35ms
memory: 1228kb
input:
50 50 1792 843 1272 547 698 1086 1174 1607 1277 1055 506 881 1445 372 1076 1770 647 1086 320 1912 18...
output:
12 45 12 12 0 12 13 0 12 14 0 12 15 0 12 16 0 12 17 0 12 18 0 12 19 0 12 20 0 12 21 0 12 22 0 12 23 ...
result:
wrong answer 1st numbers differ - expected: '34', found: '12'
Test #5:
score: 0
Wrong Answer
time: 26ms
memory: 1224kb
input:
50 50 44 1463 245 1177 1728 1335 768 475 790 623 1466 98 672 230 339 1428 872 1905 405 1260 1503 813...
output:
14 32 14 14 0 14 15 0 14 16 0 14 17 0 14 18 0 14 19 0 14 20 0 14 21 0 14 22 0 14 23 0 14 24 0 14 25 ...
result:
wrong answer 1st numbers differ - expected: '19', found: '14'
Test #6:
score: 0
Wrong Answer
time: 27ms
memory: 1224kb
input:
50 50 695 974 1078 231 500 498 1308 1666 1925 766 1994 1776 1955 1766 1191 1021 1581 1202 615 1230 1...
output:
29 39 29 29 0 29 30 0 29 31 0 29 32 0 29 33 0 29 34 0 29 35 0 29 36 0 29 37 0 29 38 0 29 39 0 30 30 ...
result:
wrong answer 1st numbers differ - expected: '11', found: '29'
Test #7:
score: 0
Time Limit Exceeded
input:
200 200 403 329 389 1103 695 1865 818 671 750 1868 1422 422 1186 1431 172 1569 460 1580 406 1049 138...
output:
46 176 46 46 0 46 47 0 46 48 0 46 49 0 46 50 0 46 51 0 46 52 0 46 53 0 46 54 0 46 55 0 46 56 0 46 57...
result:
Test #8:
score: 0
Time Limit Exceeded
input:
200 200 147 1386 1788 1493 1919 1136 861 871 1895 1006 1776 346 381 1666 296 289 568 1616 1535 531 2...
output:
82 184 82 82 0 82 83 0 82 84 0 82 85 0 82 86 0 82 87 0 82 88 0 82 89 0 82 90 0 82 91 0 82 92 0 82 93...
result:
Test #9:
score: 0
Time Limit Exceeded
input:
2000 2000 1154 852 1088 1530 639 1318 1250 1222 1341 1070 205 656 903 1491 808 317 756 1962 102 1445...
output:
251 1080 251 251 0 251 252 0 251 253 0 251 254 0 251 255 0 251 256 0 251 257 0 251 258 0 251 259 0 2...
result:
Test #10:
score: 0
Time Limit Exceeded
input:
2000 2000 1232 731 1651 991 1681 1739 776 240 829 1337 493 248 214 1852 716 325 1280 1207 380 724 11...
output:
587 1653 587 587 0 587 588 0 587 589 0 587 590 0 587 591 0 587 592 0 587 593 0 587 594 0 587 595 0 5...