Submission #198710

# Submission time Handle Problem Language Result Execution time Memory
198710 2020-01-27T12:45:18 Z Neklixx PIN (CEOI10_pin) C++14
30 / 100
71 ms 9064 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e3 + 28;
map<string, int> mapa[MAXN];

string to2(int x) {
	string res = "";
	while (x > 0) {
		res += (x % 2);
		x /= 2;
	}
	char zero = 0;
	while (res.size() < 4) {
		res += zero;
	}
	return res;
}
int n;
vector<string> v;

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
    int d;
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		v.pb(s);
	}    
	int ans = 0;
	for (int mask = 0; mask < (1 << 4); mask++) {
		string now = to2(mask);
		int sm = 0;
		for (int i = 0; i < now.size(); i++) {
			sm += now[i];
		}	
		if (sm != 4 - d)
			continue;
		for (int i = 0; i < n; i++) {
			string t = "";
			for (int j = 0; j < now.size(); j++) {
				if (now[j] == 0)
					continue;
				t += v[i][j];
			}
			mapa[mask][t]++;
		}
		for (auto to : mapa[mask]) {
			ans += ((to.S * (to.S - 1)) / 2);
		}
	}
	cout << ans << endl;
    return 0;
}

Compilation message

pin.cpp: In function 'int main()':
pin.cpp:54:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < now.size(); i++) {
                   ~~^~~~~~~~~~~~
pin.cpp:61:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < now.size(); j++) {
                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1016 KB Output is correct
2 Incorrect 7 ms 504 KB Output isn't correct
3 Incorrect 5 ms 504 KB Output isn't correct
4 Correct 29 ms 2412 KB Output is correct
5 Correct 32 ms 2540 KB Output is correct
6 Incorrect 26 ms 1652 KB Output isn't correct
7 Incorrect 23 ms 1652 KB Output isn't correct
8 Correct 35 ms 2800 KB Output is correct
9 Correct 52 ms 3304 KB Output is correct
10 Incorrect 53 ms 2796 KB Output isn't correct
11 Incorrect 28 ms 1652 KB Output isn't correct
12 Incorrect 23 ms 2796 KB Output isn't correct
13 Incorrect 16 ms 1652 KB Output isn't correct
14 Incorrect 9 ms 1652 KB Output isn't correct
15 Incorrect 12 ms 2800 KB Output isn't correct
16 Correct 71 ms 9064 KB Output is correct
17 Incorrect 66 ms 2920 KB Output isn't correct
18 Incorrect 13 ms 2800 KB Output isn't correct
19 Incorrect 12 ms 2800 KB Output isn't correct
20 Incorrect 12 ms 2800 KB Output isn't correct