Submission #97392

# Submission time Handle Problem Language Result Execution time Memory
97392 2019-02-15T17:13:56 Z Mercenary Parametriziran (COCI19_parametriziran) C++11
110 / 110
1465 ms 3700 KB
#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

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 time Memory Grader output
1 Correct 46 ms 3700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2160 KB Output is correct
2 Correct 40 ms 1968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 2284 KB Output is correct
2 Correct 88 ms 3616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 2180 KB Output is correct
2 Correct 90 ms 1720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 2244 KB Output is correct
2 Correct 133 ms 1520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 455 ms 3408 KB Output is correct
2 Correct 221 ms 2344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 505 ms 2056 KB Output is correct
2 Correct 200 ms 2032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 568 ms 2764 KB Output is correct
2 Correct 614 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 919 ms 2288 KB Output is correct
2 Correct 377 ms 2012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1465 ms 2856 KB Output is correct
2 Correct 1239 ms 3060 KB Output is correct