QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#719038#5499. AliasesSakib_SafwanWA 99ms99116kbC++204.1kb2024-11-06 22:11:502024-11-06 22:11:51

Judging History

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

  • [2024-11-06 22:11:51]
  • 评测
  • 测评结果:WA
  • 用时:99ms
  • 内存:99116kb
  • [2024-11-06 22:11:50]
  • 提交

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;
    }
    
    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 << 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;
            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();
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 78996kb

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: 99ms
memory: 99116kb

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)