Submission #97392

#TimeUsernameProblemLanguageResultExecution timeMemory
97392MercenaryParametriziran (COCI19_parametriziran)C++11
110 / 110
1465 ms3700 KiB
#include<bits/stdc++.h>

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 5e4 + 5;

int n , m;
vector<string> v[1 << 6];
ll res = 0;

void Cal(int x , int y)
{
    vector<string> t;
    t.reserve(v[x].size());
    for(auto c : v[x])
    {
        string tmp;
        for(int j = 0 ; j < m ; ++j)
            if(((x >> j) & 1) && ((y >> j) & 1))tmp.pb(c[j]);
        t.pb(tmp);
    }
    sort(t.begin(),t.end());
    for(auto c : v[y])
    {
        string tmp;
        for(int j = 0 ; j < m ; ++j)
            if(((x >> j) & 1) && ((y >> j) & 1))tmp.pb(c[j]);
        res += upper_bound(t.begin(),t.end(),tmp) - lower_bound(t.begin(),t.end(),tmp);
    }
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n >> m;
    for(int i = 1 ; i <= n ; ++i){
        string s;
        cin >> s;
        int key = 0;
        for(int j = 0 ; j < m ; ++j)
            if(s[j] != '?')key |= (1 << j);
        v[key].pb(s);
    }
    for(int i = 0 ; i < (1 << m) ; ++i)
        for(int j = 0 ; j < (1 << m) ; ++j)
            Cal(i , j);
    res -= n;
    cout << res / 2;
}

Compilation message (stderr)

parametriziran.cpp: In function 'int main()':
parametriziran.cpp:39:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(taskname".INP", "r",stdin) ,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
         freopen(taskname".OUT", "w",stdout);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
parametriziran.cpp:39:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
#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...
#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...