Submission #198861

#TimeUsernameProblemLanguageResultExecution timeMemory
198861ZwariowanyMarcinParametriziran (COCI19_parametriziran)C++14
110 / 110
184 ms2040 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define LL long long #define ld long double #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, j, n) for(int i = j; i <= n; ++i) #define boost cin.tie(0), ios_base::sync_with_stdio(0); using namespace std; const int nax = 50005; int n, m; char s[nax][10]; vector <int> v[64]; LL ans; unordered_map <int, int> x; int daj(int nr, int mask) { int y = 0; for (int i = 0; i < m; ++i) { y *= 26; if ((mask >> i) & 1) y += (s[nr][i] - 'a'); } return y; } int main() { scanf ("%d%d", &n, &m); for (int i = 0; i < n; ++i) { scanf ("%s", s[i]); int mask = 0; for (int j = 0; j < m; ++j) if (s[i][j] != '?') mask += 1 << j; v[mask].pb(i); } for (int m1 = 0; m1 < (1 << m); ++m1) for (int m2 = m1; m2 < (1 << m); ++m2) { x.clear(); LL res = 0; int p = (m1 & m2); for (auto it : v[m1]) x[daj(it, p)]++; for (auto it : v[m2]) res += x[daj(it, p)]; if (m1 != m2) ans += res; else ans += (res - ss(v[m1])) / 2; } printf ("%lld", ans); return 0; }

Compilation message (stderr)

parametriziran.cpp: In function 'int main()':
parametriziran.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%d", &n, &m);
  ~~~~~~^~~~~~~~~~~~~~~~
parametriziran.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%s", s[i]);
   ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...