QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#347128 | #8340. 3 Sum | ucup-team266# | WA | 396ms | 25560kb | C++23 | 3.0kb | 2024-03-09 11:17:45 | 2024-03-09 11:17:47 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
vector<ll> primes={
100000000000000003,
100000000000000013,
100000000000000019,
100000000000000021,
100000000000000049,
100000000000000081,
100000000000000099,
100000000000000141,
100000000000000181,
100000000000000337,
100000000000000339,
100000000000000369,
100000000000000379,
100000000000000423,
100000000000000519,
100000000000000543,
100000000000000589,
100000000000000591,
100000000000000609,
100000000000000669,
100000000000000691,
100000000000000781,
100000000000000787,
100000000000000817,
100000000000000819,
100000000000000871,
100000000000000889,
100000000000001053,
100000000000001071,
100000000000001093,
100000000000001099,
100000000000001107,
100000000000001201,
100000000000001219,
100000000000001221,
100000000000001243,
100000000000001249,
100000000000001287,
100000000000001293,
100000000000001327,
100000000000001399,
100000000000001429,
100000000000001449,
100000000000001459,
100000000000001573,
100000000000001603,
100000000000001623,
100000000000001641,
100000000000001903,
100000000000001921
};
const int B=10;
vector<ll> vec[505],mval[3];
int val[20020];
map<vector<ll>,int> Mp;
mt19937_64 rnd(20210448);
int main()
{
shuffle(primes.begin(),primes.end(),rnd);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,k;
cin>>n>>k;
mval[0].resize(B);
mval[1].resize(B);
mval[2].resize(B);
for(int i=0;i<k;i++)
for(int j=0;j<B;j++)
mval[1][j]=(mval[1][j]*10+9)%primes[j];
for(int j=0;j<B;j++)
mval[2][j]=mval[1][j]*2%primes[j];
for(int i=1;i<=n;i++)
{
string s;
cin>>s;
rev(s);
memset(val,0,sizeof(val));
for(int j=0;j<sz(s);j++)
val[j%k]+=(s[j]^48);
while(true)
{
for(int j=0;j<k;j++)
{
s[j+1]+=s[j]/10;
s[j]%=10;
}
if(!s[k]) break;
s[0]+=s[k];
s[k]=0;
}
vec[i].resize(B);
for(int j=k-1;j>=0;j--)
for(int x=0;x<B;x++)
vec[i][x]=(vec[i][x]*10+val[j])%primes[x];
}
int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
vector<ll> tmp(B);
for(int x=0;x<B;x++)
tmp[x]=(vec[i][x]+vec[j][x])%primes[x];
Mp[tmp]++;
}
for(int j=i;j<=i;j++)
for(int x=0;x<3;x++)
{
vector<ll> tmp(B);
for(int y=0;y<B;y++)
tmp[y]=(mval[x][y]+primes[y]-vec[j][y])%primes[y];
ans+=Mp[tmp];
}
}
cout<<ans<<'\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
4 1 0 1 10 17
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 85ms
memory: 25560kb
input:
500 859 7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 396ms
memory: 25476kb
input:
500 17336 11871159223687829792235950161360414494835561698697083734067767137675360383685281188659130037014315194336852912974981311847615186584425521253435544161148142093848317807514306269134525728824246028271538975878964854109909073587561782234855194213461696355772305598026008223090250526997551814628...
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 45ms
memory: 4540kb
input:
500 1 751324443898124078584847834484321089092662321556147445230263526014359393841194947303407593948729802551881289193716611867931891257925091769456350249725997883453296895094445731130479434019358742162771547784250401546380268386074363779242500860317042151185119666027858022664683818314351285215150806...
output:
0
result:
wrong answer 1st numbers differ - expected: '2327631', found: '0'