Witam, zrobiłem to zadanie i dostaję za nie tylko 12,5 punktów, nie mogę znaleźć żadnego rozsądnego wytłumaczenia dlaczego, czy ktoś byłby mi to w stanie wyjaśnić?
Pozdrawiam
#include <bits/stdc++.h>
using namespace std;
unsigned long long int convert(string str)
{
unsigned long long int a = 0;
int pom;
for (int i = 0;i<str.length();i++)
{
if (str[i] <= 99)
pom = 2;
else if (str[i] <= 102)
pom = 3;
else if (str[i] <= 105)
pom = 4;
else if (str[i] <= 108)
pom = 5;
else if (str[i] <= 111)
pom = 6;
else if (str[i] <= 115)
pom = 7;
else if (str[i] <= 118)
pom = 8;
else pom = 9;
a *= 10;
a += pom;
}
return a;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n,k;
cin >> n >> k;
pair <unsigned long long int, string> word[n];
for (int i = 0;i<n;i++)
{
cin >> word[i].second;
word[i].first = convert(word[i].second);
}
sort(word, word + n);
int qry[k];
bool brak[k];
for (int i = 0;i<k;i++)
{
cin >> qry[i];
brak[i] = 1;
}
sort(qry, qry + k);
int j = 0;
for (int i = 0;i<n;i++)
{
if (word[i].first == qry[j])
{
cout << word[i].second << " ";
brak[j] = 0;
}
else if (word[i].first > qry[j])
{
if (brak[j] == 1)
cout << "BRAK";
cout << "\n";
j++;
if (j == k) break;
i--;
}
}
for (int i = j;i<k;i++)
cout << "BRAK\n";
return 0;
}
created
last reply
- 8
replies
- 684
views
- 4
users
- 1
like
- 1
link