# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
591091 |
2022-07-06T20:44:48 Z |
kolo |
Cards (LMIO19_korteles) |
C++14 |
|
1000 ms |
33260 KB |
#include <bits/stdc++.h>
using namespace std;
map<string,int> mg,md,ml,mp;
set<string> se;
long long w,n;
string s,st;
char pg,pd,lg,ld;
int p[100],p1,p2;
inline bool czy_pozioma_os_symetrii(string karta){
// string karta = ""s + pg+lg+pd+ld;
return (karta[0] == karta[2] && karta[1]==karta[3]);
}
inline bool czy_pionowa_os_symetrii(string karta){
// string karta = ""s + pg+lg+pd+ld;
return (karta[0] == karta[1] && karta[2]==karta[3]);
}
inline bool symetria_osiowa(string karta){
// string karta = ""s + pg+lg+pd+ld;
return karta[0] == karta[3] && karta[1]==karta[2];
}
inline string lusterko_pionowo(string karta){
return ""s + karta[1]+karta[0]+karta[3]+karta[2];
}
inline string lusterko_poziomo(string karta){
// string karta = ""s + pg+lg+pd+ld;
return ""s + karta[2]+karta[3]+karta[0]+karta[1];
}
char trojka(string karta){
if ((karta[0] == karta[1]) && karta[2] == karta[0] || karta[3] == karta[0])
return karta[0];
if ((karta[2] == karta[3]) && karta[0] == karta[2] || karta[1] == karta[2])
return karta[2];
return '.';
}
int trojka_pozycja(string karta, char znak){
if(karta[0]!=znak) return 3;
if(karta[1]!=znak) return 2;
if(karta[2]!=znak) return 1;
if(karta[3]!=znak) return 0;
}
string trojka_zrob_szablon(string karta, char znak){
return ""s + znak+znak+znak+znak;
}
int czy_pozostale_takie_same(string karta, int pozycja){
if (pozycja == 0) return (karta[0] == karta[1] && karta[0] == karta[2]);
else
for(int i = 1; i<4;i++){
if (karta[i]!=karta[0]) return false;
}
return true;
}
int liczba_kart_zgodnych_z_szablonem_katowym(string szablon, int pozycja){
int wynik = 0;
for(char c = 'A'; c<= 'Z'; c++){
szablon[pozycja] = c;
if (se.count(szablon)) wynik++;
}
return wynik;
}
int liczba_kart_z_polaczeniem_katowym(string karta){
int liczba_kart_z_polaczeniem_katowym = 0;
for(int poz =0; poz < 4; poz++)
if(czy_pozostale_takie_same(karta,poz)){
liczba_kart_z_polaczeniem_katowym +=
liczba_kart_zgodnych_z_szablonem_katowym(karta,poz);
}
return liczba_kart_z_polaczeniem_katowym;
}
int main(){
iostream::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int t = 0;t < n;t++){
cin >> lg >> pg >> ld >> pd;
string karta = ""s + pg+lg+pd+ld;
mg[""s + lg + pg]++;
md[""s + ld + pd]++;
ml[""s + lg + ld]++;
mp[""s + pg + pd]++;
if(czy_pozioma_os_symetrii(karta)) w--;
if(czy_pionowa_os_symetrii(karta)) w--;
if(symetria_osiowa(karta)){
if(se.count(lusterko_pionowo(karta))) w-=3;
} else if(trojka(karta)!='.') {
w-= liczba_kart_z_polaczeniem_katowym(karta);
} else {
if(se.count(lusterko_pionowo(karta))) w--;
if(se.count(lusterko_poziomo(karta))) w--;
}
se.insert(karta);
//cout << "wczesniej : " << w << "\n";
}
//cout << "g\n";
for(auto e : md){
s=e.first;
w+=e.second*mg[s];
//cout << w << " : " << e.first << " : " << e.second << " : " << s << " : " << mg[s] << "\n";
}
//cout << "p\n";
for(auto e : mp){
s=e.first;
w+=e.second*ml[s];
//cout << w << " : " << e.first << " : " << e.second << " : " << s << " : " << ml[s] << "\n";
}
//cout << "odp: ";
cout << w;
return 0;
}
Compilation message
korteles.cpp: In function 'char trojka(std::string)':
korteles.cpp:35:32: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
35 | if ((karta[0] == karta[1]) && karta[2] == karta[0] || karta[3] == karta[0])
korteles.cpp:37:32: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
37 | if ((karta[2] == karta[3]) && karta[0] == karta[2] || karta[1] == karta[2])
korteles.cpp: In function 'int czy_pozostale_takie_same(std::string, int)':
korteles.cpp:54:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
54 | else
| ^~~~
korteles.cpp:58:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
58 | return true;
| ^~~~~~
korteles.cpp: In function 'int trojka_pozycja(std::string, char)':
korteles.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
46 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
33260 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
89 ms |
4584 KB |
Output is correct |
3 |
Correct |
847 ms |
25732 KB |
Output is correct |
4 |
Correct |
402 ms |
15192 KB |
Output is correct |
5 |
Correct |
404 ms |
15132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |