답안 #232516

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
232516 2020-05-17T09:27:25 Z VEGAnn Parametriziran (COCI19_parametriziran) C++14
77 / 110
379 ms 65540 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ft first
#define sd second
#define sz(x) ((int)x.size())
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
const int N = 50100;
const int Z = 28;
gp_hash_table<string, int> mem;
string s[N], t;
int n, m;
ll ans = 0;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> m;

    for (int i = 0; i < n; i++){
        cin >> s[i];

        for (int msk = 0; msk < (1 << m); msk++){
            bool bad = 0;
            t = "";

            for (int j = 0; j < m && !bad; j++)
                if (msk & (1 << j)) {
                    if (s[i][j] == '?')
                        bad = 1;
                    else t += "#";
                } else t += s[i][j];

            if (!bad)
                mem[t]++;
        }
    }

    for (int i = 0; i < n; i++){
        for (int msk = 0; msk < (1 << m); msk++){
            t = "";

            for (int j = 0; j < m; j++)
                if (msk & (1 << j)) {
                    if (s[i][j] == '?')
                        t += "#";
                    else t += "?";
                } else t += s[i][j];

            if (mem.find(t) != mem.end())
                ans += mem[t];
        }
    }

    cout << (ans - n) / 2;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 2048 KB Output is correct
2 Correct 19 ms 2176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2048 KB Output is correct
2 Correct 29 ms 2108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 4344 KB Output is correct
2 Correct 36 ms 3196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 4344 KB Output is correct
2 Correct 63 ms 6644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 20572 KB Output is correct
2 Correct 96 ms 2624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 379 ms 39240 KB Output is correct
2 Correct 130 ms 3196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 191 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 170 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 155 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -