QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722088 | #5499. Aliases | Sakib_Safwan | AC ✓ | 15217ms | 409176kb | C++20 | 4.1kb | 2024-11-07 17:46:44 | 2024-11-07 17:46:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
//#define int long long
// Don't Start typing till you complete the idea.
// Check these things for WA and before submitting
// 1. Did you clear all the global arrays
// 2. Did you checked your <= >= < >
// 3. Did you take the input properly. Did you use break or return while taking input?
// 4. Did you divide by 0.
// 5. Check array , vector , etc size
// 6. in the while loop did you miss something that would cause infinite loop?
// 7. Did you save your dp?
// 8. Are you trying to use something after deleting it?
// 9. Did you read the problem statement wrong?
// 10. Did you check the constrains of the problem properly
// 11. Did you checked for smaller cases like 1 , 0 , etc
// 12. Is it something to with overflow?
// 13. Did you initialized all the variables properly?
// 14. Did you use the formulas correctly?
// STRESS TESTING !!!!!! STRESS TESTING !!!!!
// STRESS Testing Not working?
// Stress test for multiple cases?
// Stress test for big inputs?
// Stress test for really small inputs?
// Even then if it doesn't work -> Did you wrote the wrong Brute force code
// Check these things if you are not generating ideas
// 1. Did you try thinking it in reverse?
// 2. Read the problem statement again
// 3. Check the constraints again
// 4. Try smaller cases in notebook and try to expand
// 5. Think about invariants
// 6. Think simpler ideas maybe?
// 7. Think brute force and try to get something out of it.
// 8. Maybe take a deep breath and take a break for few minutes and drink some water? :3
int primes[] = {285897553, 745494041, 693888673, 950758511, 282174533, 847345579, 722520917, 354688703, 963459817, 139793893};
const int MOD1 = 127657753, MOD2 = 987654319;
const int p1 = 137, p2 = 277;
const int N = 2e5 + 9;
// pair<int,int> fst[6][N] , lst[6][N];
// string prs[N][6] , srs[N][6];
int xtr[10][10];
void GG()
{
int n;
cin >> n;
int mxd = 0;
int temp = 1;
memset(xtr , 0 , sizeof xtr);
for(int j = 0; ; j++){
if(n <= temp){
mxd = j;
break;
}
temp *= 10;
}
mxd = max(mxd , 1);
int ans = mxd;
vector<pair<string , string>> vs(n);
for(auto &s : vs) {
cin >> s.first;
cin >> s.second;
}
int hudai[3] = {0 , 0 , mxd};
map<string , int> freq[mxd + 3][mxd + 3];
for(int i = 0; i < n; i++){
string jtemp = "";
for(int j = 0; j <= mxd; j++){
string ktemp = "";
if(j >= 1 && j <= vs[i].first.size()) jtemp.pb(vs[i].first[j - 1]);
for(int k = 0; k <= mxd; k++){
if(j == 0 && k == 0) continue;
if(k >= 1 && k <= vs[i].second.size()) ktemp.pb(vs[i].second[k - 1]);
string kora = jtemp + ktemp;
// cout << i << ' ' << j << ' ' << k << endl;
// cout << jtemp << '\n' << ktemp << '\n' << kora << endl;
xtr[j][k] = max(xtr[j][k] , ++freq[j][k][kora]);
}
}
}
for(int i = 0; i <= mxd; i++){
for(int j = 0; j <= mxd; j++){
if(i == 0 && j == 0) continue;
// int kemne = 0;
temp = 1;
// cout << i << ' ' << j << ' ' << xtr[i][j] << ' ' << endl;
for(int k = 0; ; k++){
if(xtr[i][j] <= temp){
xtr[i][j] = k;
break;
}
temp *= 10;
}
if(i + j + xtr[i][j] <= ans){
ans = i + j + xtr[i][j];
hudai[0] = i;
hudai[1] = j;
hudai[2] = xtr[i][j];
}
}
}
cout << hudai[0] << ' ' << hudai[1] << ' ' << hudai[2] << endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int ttc=1;
cin>>ttc;
//int cnt=0;
while(ttc--)
{
//cout<<"Case "<<++cnt<<": ";
GG();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
1 11 sven eriksson erik svensson sven svensson erik eriksson bjorn eriksson bjorn svensson bjorn bjornsson erik bjornsson sven bjornsson thor odinsson odin thorsson
output:
1 1 0
result:
ok correct! (1 test case)
Test #2:
score: 0
Accepted
time: 84ms
memory: 23560kb
input:
6 1 g u 14643 gj ek hc bi hi ke ab ij hk cj ha bi ag fe eb ej hd ei bf gj ke dd ib jd id jb gd ei cj bi bi hg ic dh ke gk af eg fg dd fe fa be ge hf kj ih ci gg jf ed dd eh gi cc kd ka fd af gb ka fe ja ed bc hi eg cf gg ff kf gf ii ch hh ec ei ec cd gc bh hb dd id ce bk ib ic bf kk gh cd hb he if g...
output:
1 0 0 2 2 1 0 1 1 1 0 2 1 1 1 2 0 1
result:
ok correct! (6 test cases)
Test #3:
score: 0
Accepted
time: 528ms
memory: 31112kb
input:
6 5000 dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...
output:
3 0 1 0 1 3 1 1 2 2 0 2 1 2 1 3 0 1
result:
ok correct! (6 test cases)
Test #4:
score: 0
Accepted
time: 15217ms
memory: 355976kb
input:
6 113503 hxihfx mrqehftb oqmcc bwrbqomg dokyjc kuaiu hhfubp aleme xcnbe shxaqrf kzmqym geclklta jnxjq nppjx xeloxixa owsxnnj pzlvbyuk leioq xipez hoxgsml esujubw cwwzpei fekvoee vbxlts xjhcrkx qicmbmen rskvnrcx mpzpvvye lkkmkstn wlptoh wqgvr qbryq cqxydbr fzdxdrv wzofngxt keqwwhdl fkomzb sckpev geqe...
output:
4 0 1 2 2 1 1 3 1 3 0 2 1 2 2 1 1 3
result:
ok correct! (6 test cases)
Test #5:
score: 0
Accepted
time: 12291ms
memory: 409176kb
input:
6 1331 hidkxivneczxfctnobbqpxsgneaivgbodiejoqgbdthwsdsfzkxcdtzumcfdoawihskkwkehjdezgazzphrnkgncimntusqjqwimwbsztbzceqnwmnzzezwzazakknfwvdsyglpplwgnhwcgpriuwdmbvvlxaoruuuugamntnuqlvslsgvehhegjqpkcskonosndngfkokjcrqewtzzmypimrsoqqffwwzgzwhgfrrxmtptzfnretnoqjprpgqdhxcrccphsdmouuuidojxcyiknpfrrygjgwgwkb...
output:
1 2 0 3 1 0 4 1 0 2 3 0 0 5 0 0 0 6
result:
ok correct! (6 test cases)