提出 #74718222
ソースコード 拡げる
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
bool st;
using namespace std;
/*Ctrl+Alt+G F*/
namespace AC{
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
#define Setprecision 15
#define between ' '
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(T x){for(auto &y:x)*this<<y<<between;*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-Setprecision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(T c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(std::string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}void flush(){Fwrite::flush();}}cout;}
#undef Setprecision
using ll=long long;
int fa[50000010],v[500010];
int find_root(int x){
int r=x;
while(r!=fa[r])r=fa[r];
int c=x;
while(c!=r){
int nxt=fa[c];
fa[c]=r;
c=nxt;
}
return r;
}
void solve(){
int n,m;
cin>>n>>m;
for(int i=0;i<=m;++i)fa[i]=i;
int len=m;
int dif=0;
for(int i=0;i<n;++i){
int a;
cin>>a;
if(a>len)continue;
if(a<=len-a){
for(int x=0;x<a;++x)fa[dif+x]=dif+a+x;
dif+=a;
len-=a;
}
else{
for(int x=a;x<=len;++x)fa[dif+x]=dif+x-a;
len=a-1;
}
}
ll ans=0;
for(ll k=1;k<=m;++k){
int root=find_root(k);
ll rem=root-dif;
ll cost=k-rem;
ans^=(k*cost);
}
cout<<ans<<"\n";
}
}
bool ed;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef debug
cerr<<"----------------------------------- START -----------------------------------\n";
#endif
int t=1;
cin>>t;
while(t--)AC::solve();
#ifdef debug
cerr<<"\n--------------------------------- INPUT END ---------------------------------\n";
AC::cout.flush();
cerr<<"\n------------------------------------ END ------------------------------------\n";
cerr<<setprecision(3)<<fixed<<"Total Memory : "<<left<<setw(10)<<(&ed-&st)/1048576.0<<" \tMB\n"<<" "<<left<<setw(10)<<(&ed-&st)/1024.0<<" \tKB\n"<<" "<<left<<setw(10)<<(&ed-&st)<<" \tByte\n";
#endif
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Greedy Customer |
| ユーザ | nut321 |
| 言語 | C++23 (GCC 15.2.0) |
| 得点 | 0 |
| コード長 | 5233 Byte |
| 結果 | TLE |
| 実行時間 | > 2000 ms |
| メモリ | 199056 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 700 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt |
| All | 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 01_handmade_16.txt, 01_handmade_17.txt, 01_handmade_18.txt, 01_handmade_19.txt, 01_handmade_20.txt, 01_handmade_21.txt, 01_handmade_22.txt, 01_handmade_23.txt, 01_handmade_24.txt, 01_handmade_25.txt, 01_handmade_26.txt, 01_handmade_27.txt, 01_handmade_28.txt, 01_handmade_29.txt, 01_handmade_30.txt, 01_handmade_31.txt, 01_handmade_32.txt, 01_handmade_33.txt, 01_handmade_34.txt, 01_handmade_35.txt, 01_handmade_36.txt, 01_handmade_37.txt, 01_handmade_38.txt, 01_handmade_39.txt, 01_handmade_40.txt, 01_handmade_41.txt, 01_handmade_42.txt, 01_handmade_43.txt, 01_handmade_44.txt, 01_handmade_45.txt, 01_handmade_46.txt, 01_handmade_47.txt, 01_handmade_48.txt, 01_handmade_49.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt, 02_random_26.txt, 02_random_27.txt, 02_random_28.txt, 02_random_29.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3500 KiB |
| 01_handmade_00.txt | AC | 142 ms | 199052 KiB |
| 01_handmade_01.txt | AC | 145 ms | 198804 KiB |
| 01_handmade_02.txt | TLE | > 2000 ms | 198876 KiB |
| 01_handmade_03.txt | TLE | > 2000 ms | 198876 KiB |
| 01_handmade_04.txt | AC | 131 ms | 198832 KiB |
| 01_handmade_05.txt | AC | 217 ms | 198828 KiB |
| 01_handmade_06.txt | AC | 225 ms | 198828 KiB |
| 01_handmade_07.txt | AC | 142 ms | 198900 KiB |
| 01_handmade_08.txt | AC | 141 ms | 198900 KiB |
| 01_handmade_09.txt | AC | 143 ms | 199008 KiB |
| 01_handmade_10.txt | AC | 143 ms | 198944 KiB |
| 01_handmade_11.txt | AC | 252 ms | 198832 KiB |
| 01_handmade_12.txt | TLE | > 2000 ms | 198832 KiB |
| 01_handmade_13.txt | TLE | > 2000 ms | 198780 KiB |
| 01_handmade_14.txt | TLE | > 2000 ms | 198888 KiB |
| 01_handmade_15.txt | AC | 659 ms | 198888 KiB |
| 01_handmade_16.txt | AC | 269 ms | 198812 KiB |
| 01_handmade_17.txt | AC | 219 ms | 198828 KiB |
| 01_handmade_18.txt | AC | 150 ms | 134632 KiB |
| 01_handmade_19.txt | AC | 223 ms | 198816 KiB |
| 01_handmade_20.txt | AC | 221 ms | 199052 KiB |
| 01_handmade_21.txt | AC | 217 ms | 198888 KiB |
| 01_handmade_22.txt | AC | 217 ms | 198888 KiB |
| 01_handmade_23.txt | AC | 216 ms | 198816 KiB |
| 01_handmade_24.txt | AC | 510 ms | 198804 KiB |
| 01_handmade_25.txt | AC | 404 ms | 198876 KiB |
| 01_handmade_26.txt | AC | 401 ms | 198780 KiB |
| 01_handmade_27.txt | AC | 1939 ms | 198808 KiB |
| 01_handmade_28.txt | AC | 153 ms | 198752 KiB |
| 01_handmade_29.txt | AC | 777 ms | 198888 KiB |
| 01_handmade_30.txt | TLE | > 2000 ms | 198560 KiB |
| 01_handmade_31.txt | TLE | > 2000 ms | 198752 KiB |
| 01_handmade_32.txt | TLE | > 2000 ms | 198828 KiB |
| 01_handmade_33.txt | TLE | > 2000 ms | 198828 KiB |
| 01_handmade_34.txt | TLE | > 2000 ms | 198924 KiB |
| 01_handmade_35.txt | TLE | > 2000 ms | 198816 KiB |
| 01_handmade_36.txt | TLE | > 2000 ms | 198520 KiB |
| 01_handmade_37.txt | TLE | > 2000 ms | 198816 KiB |
| 01_handmade_38.txt | TLE | > 2000 ms | 198552 KiB |
| 01_handmade_39.txt | TLE | > 2000 ms | 198592 KiB |
| 01_handmade_40.txt | TLE | > 2000 ms | 198476 KiB |
| 01_handmade_41.txt | AC | 1216 ms | 198888 KiB |
| 01_handmade_42.txt | AC | 954 ms | 198816 KiB |
| 01_handmade_43.txt | TLE | > 2000 ms | 198828 KiB |
| 01_handmade_44.txt | TLE | > 2000 ms | 198920 KiB |
| 01_handmade_45.txt | TLE | > 2000 ms | 198804 KiB |
| 01_handmade_46.txt | AC | 568 ms | 198804 KiB |
| 01_handmade_47.txt | AC | 558 ms | 198780 KiB |
| 01_handmade_48.txt | AC | 447 ms | 199008 KiB |
| 01_handmade_49.txt | AC | 515 ms | 198828 KiB |
| 02_random_00.txt | AC | 148 ms | 23156 KiB |
| 02_random_01.txt | AC | 147 ms | 23176 KiB |
| 02_random_02.txt | AC | 147 ms | 23176 KiB |
| 02_random_03.txt | AC | 144 ms | 23132 KiB |
| 02_random_04.txt | AC | 216 ms | 198828 KiB |
| 02_random_05.txt | AC | 212 ms | 198920 KiB |
| 02_random_06.txt | AC | 209 ms | 198924 KiB |
| 02_random_07.txt | AC | 209 ms | 198836 KiB |
| 02_random_08.txt | AC | 223 ms | 198816 KiB |
| 02_random_09.txt | AC | 213 ms | 199008 KiB |
| 02_random_10.txt | AC | 209 ms | 199008 KiB |
| 02_random_11.txt | AC | 218 ms | 199056 KiB |
| 02_random_12.txt | AC | 221 ms | 198780 KiB |
| 02_random_13.txt | AC | 207 ms | 198876 KiB |
| 02_random_14.txt | AC | 147 ms | 198780 KiB |
| 02_random_15.txt | AC | 181 ms | 198924 KiB |
| 02_random_16.txt | AC | 316 ms | 199052 KiB |
| 02_random_17.txt | AC | 328 ms | 198816 KiB |
| 02_random_18.txt | AC | 31 ms | 28320 KiB |
| 02_random_19.txt | AC | 67 ms | 60076 KiB |
| 02_random_20.txt | AC | 223 ms | 199000 KiB |
| 02_random_21.txt | AC | 224 ms | 198924 KiB |
| 02_random_22.txt | AC | 225 ms | 198752 KiB |
| 02_random_23.txt | AC | 221 ms | 199052 KiB |
| 02_random_24.txt | AC | 378 ms | 199052 KiB |
| 02_random_25.txt | AC | 283 ms | 199008 KiB |
| 02_random_26.txt | AC | 279 ms | 198752 KiB |
| 02_random_27.txt | AC | 392 ms | 198768 KiB |
| 02_random_28.txt | AC | 384 ms | 199052 KiB |
| 02_random_29.txt | AC | 377 ms | 198804 KiB |