Submission #39698467
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define ll long long
#define bl bool
ll my_pow(ll a,ll b,ll mod){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll qpow(ll a,ll b){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res*=a;
a*=a;
b>>=1;
}
return res;
}
#define db double
#define pf printf
#define pc putchar
#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
#define go(u) for(ll i=head[u];i;i=e[i].nxt)
#define enter pc('\n')
#define space pc(' ')
#define fir first
#define sec second
#define MP make_pair
#define il inline
#define inf 8e18
#define random(x) rand()*rand()%(x)
#define inv(a,mod) my_pow((a),(mod-2),(mod))
il ll read(){
ll sum=0,f=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
sum=sum*10+(ch^48);
ch=getchar();
}
return sum*f;
}
il void write(ll x){
if(x<0){
x=-x;
pc('-');
}
if(x>9) write(x/10);
pc(x%10+'0');
}
il void writeln(ll x){
write(x);
enter;
}
il void writesp(ll x){
write(x);
space;
}
}
using namespace my_std;
ll n,a[200020],lsh[15][200020],b[22],pw[22],ans=0;
int main(){
n=read();
fr(i,1,n) a[i]=read();
fr(i,1,n){
ll tmp=a[i];
while(tmp){
ans+=2*n*(tmp%10);
tmp/=10;
}
}
pw[0]=1;
fr(i,1,15) pw[i]=pw[i-1]*10;
fr(i,1,n) fr(j,0,14) lsh[j][i]=a[i]%pw[j+1];
fr(i,0,14) sort(lsh[i]+1,lsh[i]+n+1);
fr(i,1,n){
fr(j,0,14){
ll x=pw[j+1]-1-(a[i]%pw[j+1])+1;
x=lower_bound(lsh[j]+1,lsh[j]+n+1,x)-lsh[j];
ans-=9*(n-x+1);
}
}
write(ans);
}
Submission Info
| Submission Time |
|
| Task |
C - All Pair Digit Sums |
| User |
AFewSuns |
| Language |
C++ (GCC 9.2.1) |
| Score |
500 |
| Code Size |
1777 Byte |
| Status |
AC |
| Exec Time |
831 ms |
| Memory |
28600 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:75:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
75 | fr(i,1,n) a[i]=read();
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:76:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
76 | fr(i,1,n){
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:84:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
84 | fr(i,1,15) pw[i]=pw[i-1]*10;
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:85:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
85 | fr(i,1,n) fr(j,0,14) lsh[j][i]=a[i]%pw[j+1];
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:85:15: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
85 | fr(i,1,n) fr(j,0,14) lsh[j][i]=a[i]%pw[j+1];
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:86:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
86 | fr(i,0,14) sort(lsh[i]+1,lsh[i]+n+1);
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:87:5: warning: ISO C++17 does not allow ‘register’ storage cl...
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
500 / 500 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt |
| All |
01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 03_rand_1_01.txt, 03_rand_1_02.txt, 03_rand_1_03.txt, 03_rand_1_04.txt, 03_rand_1_05.txt, 04_rand_2_01.txt, 04_rand_2_02.txt, 04_rand_2_03.txt, 04_rand_2_04.txt, 04_rand_2_05.txt, 05_small_digit_01.txt, 05_small_digit_02.txt, 06_large_digit_01.txt, 06_large_digit_02.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 01_sample_01.txt |
AC |
6 ms |
3492 KiB |
| 01_sample_02.txt |
AC |
2 ms |
3560 KiB |
| 01_sample_03.txt |
AC |
2 ms |
3640 KiB |
| 02_small_01.txt |
AC |
2 ms |
3524 KiB |
| 02_small_02.txt |
AC |
2 ms |
3672 KiB |
| 02_small_03.txt |
AC |
1 ms |
3696 KiB |
| 02_small_04.txt |
AC |
2 ms |
3524 KiB |
| 02_small_05.txt |
AC |
2 ms |
3524 KiB |
| 02_small_06.txt |
AC |
2 ms |
3640 KiB |
| 02_small_07.txt |
AC |
2 ms |
3496 KiB |
| 02_small_08.txt |
AC |
2 ms |
3692 KiB |
| 02_small_09.txt |
AC |
2 ms |
3660 KiB |
| 02_small_10.txt |
AC |
2 ms |
3496 KiB |
| 03_rand_1_01.txt |
AC |
828 ms |
28564 KiB |
| 03_rand_1_02.txt |
AC |
827 ms |
28600 KiB |
| 03_rand_1_03.txt |
AC |
831 ms |
28432 KiB |
| 03_rand_1_04.txt |
AC |
827 ms |
28500 KiB |
| 03_rand_1_05.txt |
AC |
826 ms |
28460 KiB |
| 04_rand_2_01.txt |
AC |
558 ms |
28408 KiB |
| 04_rand_2_02.txt |
AC |
556 ms |
28548 KiB |
| 04_rand_2_03.txt |
AC |
557 ms |
28600 KiB |
| 04_rand_2_04.txt |
AC |
559 ms |
28556 KiB |
| 04_rand_2_05.txt |
AC |
555 ms |
28568 KiB |
| 05_small_digit_01.txt |
AC |
276 ms |
28560 KiB |
| 05_small_digit_02.txt |
AC |
280 ms |
28460 KiB |
| 06_large_digit_01.txt |
AC |
286 ms |
28564 KiB |
| 06_large_digit_02.txt |
AC |
286 ms |
28432 KiB |