Submission #97391

# Submission time Handle Problem Language Result Execution time Memory
97391 2019-02-15T17:11:51 Z Mercenary Parametriziran (COCI19_parametriziran) C++11
0 / 110
687 ms 3696 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;
int 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 = i ; j < (1 << m) ; ++j)
            res += Cal(i , j);
    res -= n;
    cout << res;
}

Compilation message

parametriziran.cpp: In function 'int Cal(int, int)':
parametriziran.cpp:32:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
parametriziran.cpp: In function 'int main()':
parametriziran.cpp:38: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:38: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 Incorrect 48 ms 3696 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 2276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 2256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 2176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 2464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 219 ms 3584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 248 ms 2228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 284 ms 3020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 376 ms 2528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 687 ms 3160 KB Output isn't correct
2 Halted 0 ms 0 KB -