Submission #208420

# Submission time Handle Problem Language Result Execution time Memory
208420 2020-03-11T07:46:03 Z Atalasion PIN (CEOI10_pin) C++14
70 / 100
312 ms 10616 KB
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, d, ted[5];
map<string, int> mp;
string s[N];

ll nCr(ll x, ll y){
	ll res = 1;
	for (int i = 1; i <= x; i++){
		res = res * i;
	}
	for (int i = 1; i <= y; i++) res /= i;
	for (int i = 1; i <= x - y; i++) res /= i;
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> d;
	d = 4 - d;
	for (int i = 1; i <= n; i++){
		cin >> s[i];
	}	
	for (int mask = 1; mask < (1 << 4); mask++){
		mp.clear();
		for (int i = 1; i <= n; i++){
			string res = "";
			int cnt = 0;
			for (int j = 0; j < 4; j++){
				if (mask & (1 << j)) res += s[i][j], cnt++;
				else res += "?";
			}
		//	cout << res << '\n';
			ted[cnt] += mp[res];
			mp[res] ++;
		}
	}
	
	ted[2] -= ted[3] * 3;
	ted[1] -= ted[3] * 3;
	ted[1] -= ted[2] * 2;
	ted[0] -= ted[1] + ted[2] + ted[3];

	
	cout << ted[d];








	return 0;
}

Compilation message

pin.cpp:8:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise ("ofast")
 
pin.cpp:9:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise("unroll-loops")
# Verdict Execution time Memory Grader output
1 Correct 17 ms 6776 KB Output is correct
2 Correct 17 ms 6648 KB Output is correct
3 Incorrect 14 ms 6648 KB Output isn't correct
4 Correct 99 ms 8184 KB Output is correct
5 Correct 124 ms 8496 KB Output is correct
6 Correct 127 ms 8568 KB Output is correct
7 Correct 99 ms 8184 KB Output is correct
8 Correct 132 ms 8696 KB Output is correct
9 Correct 210 ms 10104 KB Output is correct
10 Correct 235 ms 10488 KB Output is correct
11 Correct 128 ms 8700 KB Output is correct
12 Correct 223 ms 10244 KB Output is correct
13 Correct 143 ms 8952 KB Output is correct
14 Incorrect 143 ms 8700 KB Output isn't correct
15 Incorrect 227 ms 10336 KB Output isn't correct
16 Correct 205 ms 9208 KB Output is correct
17 Correct 312 ms 10616 KB Output is correct
18 Incorrect 233 ms 9592 KB Output isn't correct
19 Incorrect 276 ms 10104 KB Output isn't correct
20 Incorrect 309 ms 10436 KB Output isn't correct