QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#719023 | #5499. Aliases | Sakib_Safwan | WA | 92ms | 98828kb | C++20 | 5.0kb | 2024-11-06 22:05:19 | 2024-11-06 22:05:19 |
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 = 1;
vector<pair<string , string>> vs(n);
for(auto &s : vs) {
cin >> s.first;
cin >> s.second;
}
for(int i = 0; i < n; i++){
string stemp = "";
// cout << i << ' ' << vs[i].first << endl;
// prs[i][0] = stemp;
for(int j = 1; j < min(mxd + 1 , (int)vs[i].first.size() + 1); j++){
stemp.pb(vs[i].first[j - 1]);
prs[i][j] = stemp;
}
for(int j = vs[i].first.size() + 1; j < mxd + 1 ; j++) prs[i][j] = prs[i][j - 1];
// for(int j = 0; j < mxd; j++) cout << i << ' ' << j << ' ' << prs[i][j] << endl;
}
for(int i = 0; i < n; i++){
string stemp = "";
// cout << i << ' ' << vs[i].second << endl;
// srs[i][0] = stemp;
for(int j = 1; j < min(mxd + 1 , (int)vs[i].second.size() + 1); j++){
stemp.pb(vs[i].second[j - 1]);
srs[i][j] = stemp;
}
for(int j = vs[i].second.size() + 1; j < mxd + 1; j++) srs[i][j] = srs[i][j - 1];
// for(int j = 0; j < mxd; j++) cout << i << ' ' << j << ' ' << srs[i][j] << endl;
}
int hudai[3] = {0 , 0 , mxd};
map<string , int> freq[mxd + 3][mxd + 3];
for(int i = 0; i < n; i++){
for(int j = 0; j <= mxd; j++){
for(int k = 0; k <= mxd; k++){
if(j == 0 && k == 0) continue;
string kora;
if(j == 0) kora = srs[i][k];
else if(k == 0) kora = prs[i][j];
else kora = prs[i][j] + srs[i][k];
// cout << i << ' ' << j << ' ' << k << endl;
// cout << kora << '\n' << prs[i][j] << '\n' << srs[i][k] << 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;
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 << i << ' ' << j << ' ' << xtr[i][j] << ' ' << endl;
}
}
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 79348kb
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:
0 0 2
result:
ok correct! (1 test case)
Test #2:
score: -100
Wrong Answer
time: 92ms
memory: 98828kb
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:
0 0 1 0 0 5 0 0 3 0 0 4 0 0 4 0 0 4
result:
wrong answer Rozwiazanie nieoptymalne! (test case 3)