QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#718634 | #5499. Aliases | Sakib_Safwan | WA | 20ms | 21760kb | C++20 | 4.6kb | 2024-11-06 21:01:12 | 2024-11-06 21:01:21 |
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];
void GG()
{
int n;
cin >> n;
int mxd = 0;
int temp = 1;
for(int j = 0; ; j++){
if(n <= temp){
mxd = j;
break;
}
temp *= 10;
}
mxd = max(mxd , 1);
vector<pair<string , string>> vs(n);
for(auto &s : vs) cin >> s.first >> s.second;
for(int i = 0; i < n; i++){
fst[0][i] = {0 , 0};
for(int j = 1; j <= mxd; j++){
fst[j][i].first = 1LL * fst[j - 1][i].first * p1 % MOD1;
fst[j][i].first = (fst[j][i].first + vs[i].first[j - 1]) % MOD1;
fst[j][i].second = 1LL * fst[j - 1][i].second * p2 % MOD2;
fst[j][i].second = (fst[j][i].second + vs[i].first[j - 1]) % MOD2;
// cout << i << ' ' << j << ' ' << fst[j][i].first << ' ' << fst[j][i].second << endl;
}
}
for(int i = 0; i < n; i++){
lst[0][i] = {0 , 0};
for(int j = 1; j <= mxd; j++){
lst[j][i].first = 1LL * lst[j - 1][i].first * p1 % MOD1;
lst[j][i].first = (lst[j][i].first + vs[i].second[j - 1]) % MOD1;
lst[j][i].second = 1LL * lst[j - 1][i].second * p2 % MOD2;
lst[j][i].second = (lst[j][i].second + vs[i].second[j - 1]) % MOD2;
// cout << i << ' ' << j << ' ' << lst[j][i].first << ' ' << lst[j][i].second << endl;
}
}
ll ans = mxd;
int hudai[3] = {0 , 0 , mxd};
for(int i = 0; i < mxd; i++){
for(int j = 0; i + j < mxd; j++){
if(i == 0 && j == 0) continue;
map<array<int , 4> , int> woo;
int mxcnt = 0;
for(int k = 0; k < n; k++){
mxcnt = max(mxcnt , ++woo[{fst[i][k].first , fst[i][k].second , lst[j][k].first , lst[j][k].second}]);
}
// cout << i << ' ' << j << ' ' << mxcnt << endl;
int tempo = mxcnt;
mxcnt = 0;
temp = 1;
for(int j = 0; ; j++){
if(tempo <= temp){
mxcnt = j;
break;
}
temp *= 10;
}
if(mxcnt + i + j < ans){
ans = mxcnt + i + j;
hudai[0] = i;
hudai[1] = j;
hudai[2] = mxcnt;
}
}
}
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: 2ms
memory: 11816kb
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: 20ms
memory: 21760kb
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 2 2 0 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nieunikalne! (test case 2)