QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55198 | #4803. Candies | GZU_addd# | WA | 13ms | 5360kb | C++ | 2.1kb | 2022-10-12 18:15:35 | 2022-10-12 18:15:37 |
Judging History
answer
#include<bits/stdc++.h>
#define ls u<<1
#define rs u<<1|1
#define fi first
#define se second
#define min amin
#define max amax
#define pb push_back
#define pq priority_queue
#define vt vector
#define lb(x) (x&-x)
#define sub(i,j) ((1LL*i-1LL*j)%k+k)%k
std::mt19937 rnd(233);
using namespace std;
using ll=long long;
using node=pair<int,int>;
using nnode=array<int,3>;
//inline int read(){
// int x=0,f=1;
// char c=getchar();
// while(c<'0'||c>'9'){
// if(c=='-') f=-1;
// c=getchar();
// }
// while(c>='0'&&c<='9'){
// x=x*10+(c^'0');
// c=getchar();
// }
// return x*f;
//}
template<typename T=int>T read(){T x;cin>>x;return x;}
template<typename U,typename V>auto min(U x,V y){return x<y?x:y;}
template<typename U,typename V>auto max(U x,V y){return x>y?x:y;}
template<typename U,typename...V>auto min(U x,V...y){return min(x,min(y...));}
template<typename U,typename...V>auto max(U x,V...y){return max(x,max(y...));}
template<typename U,typename V>bool cmin(U &x,V y){return x>y?x=y,true:false;}
template<typename U,typename V>bool cmax(U &x,V y){return x<y?x=y,true:false;}
constexpr int mod=998244353;
ll qpow(int x,int n=mod-2){ll y=1;for(;n;n>>=1,x=1LL*x*x%mod)if(n&1)y=1LL*y*x%mod;return y;}
//inline ll qpow(ll a, ll n=mod-2) { ll ans = 1; while (n) { if (n & 1) { ans *= a; }a *= a; n >>= 1; }return ans; }
constexpr int N=1e5+10,M=3e7+10;
constexpr ll inf=1e18;
ll n,a[N],x,ans,pre[N];
bool v[N];
int get(int x1){
x1+=n;
if(x1>=n)x1-=n;
return x1;
}
void solve(){
cin>>n>>x;
for(int i=0;i<n;++i)cin>>a[i];
for(int i=0;i<n;++i)pre[i]=i;
for(int i=0;i<n;++i)if(!v[i]){
// cout<<i<<" "<<pre[get(i-1)]<<'\n';
if(i!=pre[get(i-1)]&&(a[i]==a[pre[get(i-1)]]||a[i]+a[pre[get(i-1)]]==x)&&!v[i]&&!v[pre[get(i-1)]]){
v[i]=1,v[pre[get(i-1)]]=1;
++ans;
pre[i]=pre[get(pre[get(i-1)]-1)];
}
else if(i==pre[get(i-1)])break;
}
int l=0,r=n-1;
while(v[l])++l;
while(v[r])--r;
if(l<r){
while(l<r&&(a[l]==a[r]||a[l]+a[r]==x)&&!v[l]&&!v[r])++ans,++l,--r;
}
cout<<ans<<'\n';
}
int main(){
cin.sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
// for(int T=read();T--;solve());
solve();
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3644kb
input:
6 5 1 1 4 5 1 4
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
10 5 1 2 5 2 1 2 3 4 8 4
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
1 963837006 731841442
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
2 948507270 461613425 139535653
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 12ms
memory: 5040kb
input:
100000 253614967 278270961 980235896 498158919 928430171 216003120 852570559 948400591 239257297 897053668 294741177 38297442 382677591 406314558 609468974 854148233 314532768 738191552 158215003 5865826 920471827 380037059 356271729 749175328 28319050 208101106 953758996 896570759 521930645 2413736...
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 1ms
memory: 5228kb
input:
100000 2 1 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 1 2 1 1 1 2 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 1 1 2 1 1 2 2 2 2 1 2 2 2 1 1 2 1 2 1 2 2 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 2 2 1 1 2 1 1 2 2 2 2 2 2 2 1 2 1 1 2 2 1 1 2 1 1 1 1...
output:
49999
result:
ok 1 number(s): "49999"
Test #7:
score: 0
Accepted
time: 5ms
memory: 5252kb
input:
99824 2 1 1 2 1 1 1 2 1 2 2 2 2 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 2 1 2 2 1 1 2 2 1 2 1 1 1 2 2 1 2 1 1 2 1 2 1 2 2 2 1 1 2 1 2 2 2 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1 2 1 1 1 2 1 1 2 2 1 1 2 2 1 1 1 2 2 1 2 1 1 2 2 2 1 1 2 1 1 2 1 1 1 2 1 1 1 2 1 1 2 1 2 1 1 1 ...
output:
49904
result:
ok 1 number(s): "49904"
Test #8:
score: 0
Accepted
time: 8ms
memory: 5184kb
input:
100000 2094 5226 2958 8712 7230 6625 2487 4520 9360 2727 5423 5170 3199 3725 2419 9194 1946 9942 7780 9861 692 2218 5879 9116 3253 1191 710 8703 759 3019 3581 3648 105 6123 8494 6356 8000 3056 4478 2646 7457 2437 9669 4132 4585 8874 2930 9024 6773 132 4309 6496 8138 3514 531 4782 5854 1722 5046 8344...
output:
10
result:
ok 1 number(s): "10"
Test #9:
score: 0
Accepted
time: 10ms
memory: 5280kb
input:
100000 13036 23902 71466 9482 98728 78471 22915 2470 5999 53211 25994 3996 11349 30511 56448 17277 78308 18316 42069 38636 63127 26256 63985 57249 58305 64366 17839 28518 18980 95945 36316 6076 69530 96509 6940 6039 56048 41847 82118 41054 49670 95896 45891 74636 90736 75413 27251 87730 68344 66202 ...
output:
2
result:
ok 1 number(s): "2"
Test #10:
score: 0
Accepted
time: 13ms
memory: 5260kb
input:
100000 1000000000 200256279 980163173 150977009 767372228 582764043 266974730 643155483 835343794 21321428 879452350 591885316 154438918 900364435 545147788 658790005 179705816 697056697 995420303 943796510 917775810 218491919 453075898 2415016 995364028 660033907 366396048 415773047 341359040 99318...
output:
52
result:
ok 1 number(s): "52"
Test #11:
score: 0
Accepted
time: 13ms
memory: 5340kb
input:
100000 1000000000 930075041 382964463 32067726 285653188 451764399 121999168 242859626 923317013 493093976 435530600 599304758 19239760 605622974 58189530 743466763 461890312 450384720 113115571 150860432 739506450 146715736 606749237 443822591 586186363 455300271 934351943 190492840 188221364 79576...
output:
466
result:
ok 1 number(s): "466"
Test #12:
score: 0
Accepted
time: 6ms
memory: 5360kb
input:
100000 1000000000 28787963 903442008 498505673 786768844 2780988 260872048 803015736 179422223 438668270 50410272 949589728 713791959 42277723 675211206 285441462 805910070 799006739 729642043 274066126 771720227 985249963 147758876 18863375 329090560 875735992 616907347 677120292 996288994 39354661...
output:
5016
result:
ok 1 number(s): "5016"
Test #13:
score: 0
Accepted
time: 13ms
memory: 5200kb
input:
100000 1000000000 919904259 657106699 456489350 73335262 482319824 80954785 80954785 439309845 430263074 836709425 836709425 253860967 253860967 607421402 95008942 484440521 761289662 678820442 417290752 828224063 971351049 29588529 443998057 617366568 740517710 222054375 870322992 448320457 5482505...
output:
10107
result:
ok 1 number(s): "10107"
Test #14:
score: 0
Accepted
time: 8ms
memory: 5264kb
input:
100000 1000000000 774385080 964900197 365398016 744436356 503493016 496506984 440140095 139026794 311620979 87094613 912905387 752074900 938826429 697071589 27040552 218512285 781413020 218586980 898898505 425739571 55138594 489740170 484069475 457442504 143211885 541971054 541971054 102277341 56997...
output:
14852
result:
ok 1 number(s): "14852"
Test #15:
score: 0
Accepted
time: 7ms
memory: 5324kb
input:
100000 1000000000 762064238 237935762 83539103 956410339 496805469 293876386 476311967 857139149 740121784 844690650 247724925 846852127 846852127 390968943 872719626 872719626 781866487 94752143 726879321 822815540 263234519 163917251 904503819 904503819 218899653 721743564 278256436 393501898 6171...
output:
19881
result:
ok 1 number(s): "19881"
Test #16:
score: 0
Accepted
time: 5ms
memory: 5228kb
input:
100000 1000000000 773521685 53210169 87451051 63698384 63698384 87451051 106448763 9868594 965666221 965666221 359923109 304547627 304547627 562955901 237982702 762017298 720077827 157500371 104606639 450121676 383428765 123242383 962196953 977879399 451919378 514041727 904985040 203881325 176590362...
output:
24926
result:
ok 1 number(s): "24926"
Test #17:
score: 0
Accepted
time: 13ms
memory: 5248kb
input:
100000 1000000000 933814715 66185285 350381988 652183118 723703341 276296659 277472633 1026982 998973018 722527367 53171194 963898732 65060415 685876574 894604685 894604685 804152500 627238810 396815250 314298890 314298890 579573293 51934860 730845477 269154523 799932756 200067244 51934860 579573293...
output:
29943
result:
ok 1 number(s): "29943"
Test #18:
score: 0
Accepted
time: 13ms
memory: 5200kb
input:
100000 1000000000 57897508 942102492 536719025 463280975 975530922 389293162 118330387 118330387 959184761 918050065 918050065 292047793 619111506 619111506 707952207 798465709 686141037 686141037 775795227 106646738 329921037 811153537 188846463 842056436 675098719 692200871 692200871 13898261 4850...
output:
34943
result:
ok 1 number(s): "34943"
Test #19:
score: -100
Wrong Answer
time: 4ms
memory: 5300kb
input:
100000 1000000000 188142286 648998022 752674766 59777379 298683825 384966485 49558677 412759965 765244406 234755594 412759965 83829760 916170240 49558677 886539189 113460811 787290997 965392742 769971404 647356058 647356058 769971404 942276537 301797849 698202151 57723463 965392742 787290997 1654148...
output:
39863
result:
wrong answer 1st numbers differ - expected: '39865', found: '39863'