제출 #501787

#제출 시각아이디문제언어결과실행 시간메모리
501787fabijan_cikacCards (LMIO19_korteles)C++17
36 / 100
1066 ms35384 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int n;
map<string, ll> m;
ll sol = 0;
vector<string> v;

ll 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){

}

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){
        string a = v[i]; string s = "****";
        for (int i = 1; i < 16; ++i){
            s = "****"; int cnt = 0;
            if (i & 1){
                if ((s[3] != '*' && s[3] != a[0]) || (s[2] != '*' && s[2] != a[1]))
                    continue;
                s[3] = a[0]; s[2] = a[1]; ++cnt;
            }
            if (i & 2){
                if ((s[0] != '*' && s[0] != a[1]) || (s[3] != '*' && s[3] != a[2]))
                    continue;
                s[0] = a[1]; s[3] = a[2]; ++cnt;
            }
            if (i & 4){
                if ((s[0] != '*' && s[0] != a[3]) || (s[1] != '*' && s[1] != a[2]))
                    continue;
                s[0] = a[3]; s[1] = a[2]; ++cnt;
            }
            if (i & 8){
                if ((s[1] != '*' && s[1] != a[0]) || (s[2] != '*' && s[2] != a[3]))
                    continue;
                s[1] = a[0]; s[2] = a[3]; ++cnt;
            }
            if (cnt & 1)
                sol += (m[s] - dio(s, a));
            else sol -= (m[s] - dio(s, a));
        }
    }
    cout << sol / 2;

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

korteles.cpp: In function 'll dio(std::string, std::string)':
korteles.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < a.size(); ++i){
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...