QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#347193#8340. 3 Sumucup-team266#AC ✓349ms13756kbC++206.6kb2024-03-09 12:03:472024-10-13 18:47:43

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 18:47:43]
  • 管理员手动重测本题所有得分≥97分的提交记录
  • 测评结果:AC
  • 用时:349ms
  • 内存:13756kb
  • [2024-09-20 10:20:30]
  • hack成功,自动添加数据
  • (/hack/848)
  • [2024-03-18 21:48:05]
  • hack成功,自动添加数据
  • (/hack/579)
  • [2024-03-18 21:45:33]
  • hack成功,自动添加数据
  • (/hack/578)
  • [2024-03-09 12:03:48]
  • 评测
  • 测评结果:100
  • 用时:342ms
  • 内存:13676kb
  • [2024-03-09 12:03:47]
  • 提交

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,
	10000000000037,100000000000031,1000000000000037,10000000000000061,10000000000051,100000000000067,1000000000000091,10000000000000069,10000000000099,100000000000097,1000000000000159,10000000000000079,10000000000129,100000000000099,1000000000000187,10000000000000099,10000000000183,100000000000133,1000000000000223,10000000000000453,10000000000259,100000000000139,1000000000000241,10000000000000481,10000000000267,100000000000169,1000000000000249,10000000000000597,10000000000273,100000000000183,1000000000000259,10000000000000613,10000000000279,100000000000261,1000000000000273,10000000000000639,10000000000283,100000000000357,1000000000000279,10000000000000669,10000000000313,100000000000367,1000000000000297,10000000000000753,10000000000343,100000000000403,1000000000000357,10000000000000793,10000000000391,100000000000423,1000000000000399,10000000000000819,10000000000411,100000000000469,1000000000000403,10000000000000861,10000000000433,100000000000487,1000000000000487,10000000000000897,10000000000453,100000000000493,1000000000000513,10000000000000909,10000000000591,100000000000541,1000000000000613,10000000000000931,10000000000609,100000000000601,1000000000000711,10000000000000949,10000000000643,100000000000643,1000000000000741,10000000000000957,10000000000649,100000000000657,1000000000000783,10000000000000991,10000000000657,100000000000709,1000000000000811,10000000000001029,10000000000687,100000000000721,1000000000000843,10000000000001101,10000000000691,100000000000753,1000000000000873,10000000000001129,10000000000717,100000000000777,1000000000000921,10000000000001239,10000000000729,100000000000807,1000000000001003,10000000000001293,10000000000751,100000000000841,1000000000001027,10000000000001311,10000000000759,100000000000843,1000000000001063,10000000000001321,10000000000777,100000000000861,1000000000001089,10000000000001377,10000000000853,100000000000963,1000000000001117,10000000000001423,10000000000883,100000000000993,1000000000001209,10000000000001477,10000000000943,100000000001087,1000000000001269,10000000000001549,10000000000957,100000000001089,1000000000001293,10000000000001551,10000000000987,100000000001129,1000000000001347,10000000000001567,10000000000993,100000000001173,1000000000001371,10000000000001657,10000000001011,100000000001177,1000000000001413,10000000000001659,10000000001023,100000000001189,1000000000001491,10000000000001719,10000000001087,100000000001197,1000000000001503,10000000000001723,10000000001093,100000000001203,1000000000001551,10000000000001731,10000000001141,100000000001273,1000000000001617,10000000000001743,10000000001161,100000000001303,1000000000001623,10000000000001747,10000000001177,100000000001381,1000000000001669,10000000000001771,10000000001191,100000000001387,1000000000001741,10000000000001789,10000000001207,100000000001413,1000000000001749,10000000000001833,10000000001239,100000000001423,1000000000001819,10000000000001873,10000000001261,100000000001467,1000000000001839,10000000000001939,10000000001267,100000000001549,1000000000001867,10000000000002013,10000000001269,100000000001593,1000000000001897,10000000000002049,10000000001291,100000000001611,1000000000002037,10000000000002053,10000000001309,100000000001623,1000000000002161,10000000000002083,10000000001339,100000000001647,1000000000002193,10000000000002137
};
const int B=10;
vector<ll> vec[505],mval[3];
int val[20020];
map<longer,int> Mp;
const longer mod=1000000000000002493;
const longer base=327833278137219321;
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++)
			{
				val[j+1]+=val[j]/10;
				val[j]%=10;
			}
			if(!val[k]) break;
			val[0]+=val[k];
			val[k]=0;
		}
		int flg=1;
		for(int j=0;j<k;j++) if(val[j]!=9) flg=0; 
		if(flg) memset(val,0,sizeof(val));
		vec[i].resize(B);
//		for(int j=k-1;j>=0;j--) cout<<val[j];
//		cout<<"\n";
		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];
			longer H=0;
			for(auto x:tmp)
				H=(H*base+x)%mod;
			Mp[H]++;
		}
		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];
				longer H=0;
				for(auto x:tmp)
					H=(H*base+x)%mod;
				ans+=Mp[H];
			}
	}
	cout<<ans<<'\n';
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3740kb

input:

4 1
0
1
10
17

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 54ms
memory: 13652kb

input:

500 859
7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 349ms
memory: 13756kb

input:

500 17336
11871159223687829792235950161360414494835561698697083734067767137675360383685281188659130037014315194336852912974981311847615186584425521253435544161148142093848317807514306269134525728824246028271538975878964854109909073587561782234855194213461696355772305598026008223090250526997551814628...

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 42ms
memory: 3916kb

input:

500 1
751324443898124078584847834484321089092662321556147445230263526014359393841194947303407593948729802551881289193716611867931891257925091769456350249725997883453296895094445731130479434019358742162771547784250401546380268386074363779242500860317042151185119666027858022664683818314351285215150806...

output:

2327631

result:

ok 1 number(s): "2327631"

Test #5:

score: 0
Accepted
time: 47ms
memory: 3772kb

input:

500 2
408542968136435277974575411503179002415404345446801430469044749372949272333801248935236224652806667129749035002588943020176263162139056819871274824302889304493205266143688886696157147111754418731401856424401766968832165255416237731963027205324149660112574729610391396555581935236134531799950318...

output:

212002

result:

ok 1 number(s): "212002"

Test #6:

score: 0
Accepted
time: 232ms
memory: 4368kb

input:

500 11500
75411775796562109942642493394321873284995260953010112281856775261847503626737348402159485133662757032091519863427156582689971229143089317472838196453888261138079171290535429921921548971897026706656838415620603757605079012541561774699628665865662183868374645956694140356716037674688084770628...

output:

7675

result:

ok 1 number(s): "7675"

Test #7:

score: 0
Accepted
time: 242ms
memory: 7408kb

input:

500 11500
85355036663164764459816544518601485185320972076300982726542821424439713703229669576802138231401047471351087455159512255765325323540671792953715169122669767368905391325060775725733157611188832204902997772518104188947349204726490597030311894441123834099315122116302203972018409854605418988681...

output:

1070

result:

ok 1 number(s): "1070"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

1 11500
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...

output:

1

result:

ok 1 number(s): "1"

Extra Test:

score: 0
Extra Test Passed