| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 501766 | fabijan_cikac | Cards (LMIO19_korteles) | C++17 | 1066 ms | 37576 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
map<string, int> m;
int sol = 0;
vector<string> v;
int dio(string a, string b){
    for (int i = 0; i < a.size(); ++i){
        if (a[i] != '*' && a[i] != b[i])
            return 0;
    }
    return 1;
}
void solve(string a){
    for (int i = 1; i < 16; ++i){
        string s = "****";
        int cnt = 0;
        for (int j = 0; j < 4; ++j){
            if (i & (1 << j))
                ++cnt;
        }
        if (i & 1){
            s[3] = a[0]; s[2] = a[1];
        }
        if (i & 2){
            s[0] = a[1]; s[3] = a[2];
        }
        if (i & 4){
            s[0] = a[3]; s[1] = a[2];
        }
        if (i & 8){
            s[1] = a[0]; s[2] = a[3];
        }
        if (cnt & 1)
            sol += (m[s] - dio(a, s));
        else sol -= (m[s] - dio(a, s));
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n; v.resize(n);
    for (int i = 0; i < n; ++i){
        string b; cin >> v[i] >> b;
        v[i].push_back(b[1]); v[i].push_back(b[0]);
        for (int j = 0; j < 16; ++j){
            string s;
            for (int k = 0; k < 4; ++k){
                if (j & (1 << k))
                    s.push_back(v[i][k]);
                else s.push_back('*');
            }
            ++m[s];
        }
    }
    for (int i = 0; i < n; ++i)
        solve(v[i]);
    cout << sol / 2;
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
