Submission #198715

# Submission time Handle Problem Language Result Execution time Memory
198715 2020-01-27T13:05:35 Z Neklixx PIN (CEOI10_pin) C++14
0 / 100
177 ms 24808 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;
int calc(int d) {
	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);
		}
	}
	return ans;
}
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);
	}    
	vector<int> c;
	c.pb(calc(1));
	c.pb(calc(2));
	c.pb(calc(3));
	c.pb(calc(4));
	assert(d == 4);
	int ans = c[d - 1];
	//print1(ans);
	if (d == 2) {
		ans -= c[0] * 3;
	} else if (d == 3) {
		ans -= (c[1] - c[0] * 3) * 2;
		ans -= c[0] * 3;
	}
	cout << ans << endl;
    return 0;
}

Compilation message

pin.cpp: In function 'long long int calc(long long int)':
pin.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < now.size(); i++) {
                   ~~^~~~~~~~~~~~
pin.cpp:48: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 Runtime error 11 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 11 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Incorrect 8 ms 888 KB Output isn't correct
4 Runtime error 51 ms 4720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 60 ms 4972 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 60 ms 4976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 50 ms 4716 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 65 ms 5232 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 105 ms 6248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 110 ms 6632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 73 ms 5236 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 114 ms 6500 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 71 ms 5360 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Incorrect 64 ms 2672 KB Output isn't correct
15 Incorrect 107 ms 3304 KB Output isn't correct
16 Runtime error 126 ms 19176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 177 ms 24808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Incorrect 145 ms 10472 KB Output isn't correct
19 Incorrect 158 ms 11552 KB Output isn't correct
20 Incorrect 176 ms 12260 KB Output isn't correct