Submission #104580

# Submission time Handle Problem Language Result Execution time Memory
104580 2019-04-08T07:50:22 Z Hassoony Parametriziran (COCI19_parametriziran) C++17
110 / 110
804 ms 3920 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod=(1e9+7);
const ll inf=(1ll<<61);
const int MX=50009;
int n,m;
vector<string>v[(1<<7)];
string s;
unordered_map<string,int>vis;
char oo[8];
ll ans=0;
void add(string s){
    int ret=0;
    string tmp="";
    for(int j=0;j<m;j++){
        if(s[j]!='?')ret+=(1<<j);
    }
    v[ret].push_back(s);
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        scanf("%s",&oo);s=oo;
        add(s);
    }
    for(int i1=0;i1<(1<<m);i1++){
        for(int j1=0;j1<(1<<m);j1++){
            int mask1=i1,mask2=j1;
            vis.clear();
            for(auto pp:v[mask1]){
                string tmp="";
                for(int j=0;j<m;j++){
                    if((mask1&(1<<j))&&(mask2&(1<<j)))tmp+=pp[j];
                }
                vis[tmp]++;
            }
            for(auto pp:v[mask2]){
                string tmp="";
                for(int j=0;j<m;j++){
                    if((mask1&(1<<j))&&(mask2&(1<<j)))tmp+=pp[j];
                }
                ans+=vis[tmp];
            }
        }
    }
    cout<<(ans-n)/2<<endl;
}
/*
3 3
??b
c??
c?c
4 6
ab??c?
??kll?
a?k??c
?bcd??
5 2
??
b?
c?
?g
cg
*/

Compilation message

parametriziran.cpp: In function 'int main()':
parametriziran.cpp:25:23: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[8]' [-Wformat=]
         scanf("%s",&oo);s=oo;
                    ~~~^
parametriziran.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",&oo);s=oo;
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1784 KB Output is correct
2 Correct 21 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1756 KB Output is correct
2 Correct 34 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 2032 KB Output is correct
2 Correct 41 ms 1756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 2480 KB Output is correct
2 Correct 58 ms 1428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 187 ms 3920 KB Output is correct
2 Correct 75 ms 2220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 2292 KB Output is correct
2 Correct 146 ms 1844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 395 ms 3688 KB Output is correct
2 Correct 237 ms 2960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 627 ms 2804 KB Output is correct
2 Correct 269 ms 1976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 804 ms 3368 KB Output is correct
2 Correct 502 ms 3052 KB Output is correct