이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
"care a facut teste cu Lattice reduction attack e ciudat"
"linistiti va putin"
- 2023 -
*/
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#warning ai grija la ? ca l ai transformat in {
#pragma GCC optimize("Ofast")
using namespace std;
const int mod=1e9+9;
const int base=29;
string s[50001];
vector<int> hashcount[(1<<6)];
int main()
{
ifstream fin(".in");
ofstream fout(".out");
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int i,j,n,m,ans,mask,hashbuild,mask2;
bool ok;
cin >> n >> m;
for (j=1; j<=n; j++)
{
cin >> s[j];
for (i=0; i<s[j].size(); i++)
{
if (s[j][i]=='?')
s[j][i]='{';///urmatorul caracter dupa z
}
for (mask=1; mask<(1<<(m)); mask++)
{
hashbuild=0;
for (i=0; i<s[j].size(); i++)
{
if (mask&(1<<i))
hashbuild=((hashbuild*base)%mod+(s[j][i]-'a'+1))%mod;
}
hashcount[mask].push_back(hashbuild);
}
}
for (i=0;i<(1<<m);i++)
sort(hashcount[i].begin(),hashcount[i].end());
ans=0;
for (j=1; j<=n; j++)
{
mask=0;
for (i=0; i<s[j].size(); i++)
{
if (s[j][i]!='{')
{
mask=mask|(1<<i);
}
}
if (mask!=0)
{
for (mask2=0; mask2<=mask; mask2++)
{
ok=true;
for (i=0; i<s[j].size() && ok; i++)
{
if ((mask2&(1<<i)) && !(mask&(1<<i)))
ok=false;
}
if (ok)
{
hashbuild=0;
for (i=0; i<s[j].size(); i++)
{
if (mask&(1<<i))
{
if (mask2&(1<<i))
hashbuild=((hashbuild*base)%mod+('{'-'a'+1))%mod;
else
hashbuild=((hashbuild*base)%mod+(s[j][i]-'a'+1))%mod;
}
}
ans+=(lower_bound(hashcount[mask].begin(),hashcount[mask].end(),hashbuild+1)-lower_bound(hashcount[mask].begin(),hashcount[mask].end(),hashbuild));
}
}
}
else
{
ans+=n;
}
}
cout << (ans-n)/2;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
parametriziran.cpp:9:2: warning: #warning ai grija la ? ca l ai transformat in { [-Wcpp]
9 | #warning ai grija la ? ca l ai transformat in {
| ^~~~~~~
parametriziran.cpp: In function 'int main()':
parametriziran.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (i=0; i<s[j].size(); i++)
| ~^~~~~~~~~~~~
parametriziran.cpp:41:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (i=0; i<s[j].size(); i++)
| ~^~~~~~~~~~~~
parametriziran.cpp:55:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (i=0; i<s[j].size(); i++)
| ~^~~~~~~~~~~~
parametriziran.cpp:67:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (i=0; i<s[j].size() && ok; i++)
| ~^~~~~~~~~~~~
parametriziran.cpp:75:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for (i=0; i<s[j].size(); i++)
| ~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |