Submission #314663

#TimeUsernameProblemLanguageResultExecution timeMemory
314663ronnithParametriziran (COCI19_parametriziran)C++14
33 / 110
3080 ms2048 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define int long long #define num(a) a-'0' #define charr(a) (a - 'A' + 1) #define rep(i,a,b) for(int i=a;i<b;i++) #define maxs(a,b) if(b>a)a=b #define mins(a,b) if(b<a)a=b #define bin1(a) __builtin_popcount(a) #define debug(x) cerr<<"["<<#x<<":"<<x<<"] " #define debug2(a,b) debug(a);debug(b) #define debug3(a,b,c) debug2(a,b);debug(c) #define de cerr #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*b)/(__gcd(a,b)) #define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define all(a) (a).begin(), (a).end() #define vi vector<long long> #define v vector #define p pair #define pii p<int,int> #define pb push_back #define mk make_pair #define f first #define s second #define ln "\n" typedef long double ld; typedef double d; using namespace std; using namespace __gnu_pbds; int modF=1e9+7; /*OUTPUT */ int n,m; int ans = 0; // v<string> a; map<string,int> mp; bool chk(string s,int i,string b){ if(i == m){ // debug(b); // if(st.find(b) != st.end()){ // debug(b); ans += mp[b]; // return true; // } // return false; } else{ if(s[i] == '?'){ for(int j = 0;j < 26;j ++){ char ch = (char)(j + 97); b[i] = ch; if(chk(s,i + 1,b)){ // return true; } } b[i] = '?'; if(chk(s,i + 1,b)){ // return true; } } else{ b[i] = s[i]; if(chk(s,i + 1,b)){ // return true; } b[i] = '?'; if(chk(s,i + 1,b)){ // return true; } } } return false; } void solve(){ cin >> n >> m; if(m > 2){ v<string> a(n); rep(i,0,n){ cin >> a[i]; } int ans = 0; for(int i = 0;i < n;i ++){ for(int j = i + 1;j < n;j ++){ bool pos = true; for(int k = 0;k < m;k ++){ if(a[i][k] != '?' and a[j][k] != '?'){ if(a[i][k] != a[j][k]){ pos = false; } } } if(pos){ ans ++; } } } cout << ans << ln; } else{ // cout << "yes"; string x; for(int i = 0;i < n;i ++){ cin >> x; if(m == 1) chk(x,0," "); if(m == 2) chk(x,0," "); // debug(x); mp[x] ++; } cout << ans << ln; } } signed main(){ boost_io; int t=1; // cin>>t; while(t--){ solve(); } return 0; }
#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...