Submission #803132

#TimeUsernameProblemLanguageResultExecution timeMemory
803132AugustynSet (COCI21_set)C++17
40 / 110
1082 ms38264 KiB
#include<iostream> #include<vector> using namespace std; int trzecia(vector<char>&p,vector<char>&d) { int ret=0; for(int i=0;i<p.size();++i) { if(p[i]==d[i]) ret=ret*3+p[i]-'1'; else ret=ret*3+((p[i]-'0')^(d[i]-'0'))-1; } return ret; } int main() { ios_base::sync_with_stdio(0); int n,k,odp=0; cin>>n>>k; vector<vector<char>>wek(n); int doktej=1; for(int i=1;i<=k;++i) doktej*=3; vector<int>istnieje(doktej,-1); for(int i=0;i<n;++i) { wek[i].resize(k); int wtroj=0; for(int j=0;j<k;++j) { cin>>wek[i][j]; wtroj=wtroj*3+wek[i][j]-'1'; } istnieje[wtroj]=i; } for(int i=0;i<n/2;++i) { for(int j=i+1;j<n/2;++j) { int pom=istnieje[trzecia(wek[i],wek[j])]; if(pom>j) ++odp; } } for(int i=n/2;i<n;++i) { for(int j=i+1;j<n;++j) { int pom=istnieje[trzecia(wek[i],wek[j])]; if(pom!=-1&&pom<n/2||pom>j) ++odp; } } cout<<odp; }

Compilation message (stderr)

Main.cpp: In function 'int trzecia(std::vector<char>&, std::vector<char>&)':
Main.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0;i<p.size();++i)
      |                 ~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:51:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   51 |             if(pom!=-1&&pom<n/2||pom>j)
      |                ~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...