Task: | Ruudukko |
Sender: | Juho |
Submission time: | 2019-10-01 17:29:17 +0300 |
Language: | C++ (C++11) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:11:14: error: 'x' was not declared in this scope cin>>x; ^ input/code.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j=0; j<v.size();j++){ ~^~~~~~~~~ input/code.cpp:44:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0;i<u.size();i++){ ~^~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<vector<char>>v; vector<int>u; for(int i=0;i<n;i++){ cin>>x; vector<char>f; f.push_back('a'); char muisti ='a'; for(int j=1;j<x.size();j++){ int y=0; while(y<j){ if(x[y]==x[j]){ f.push_back(f[y]); break; } y++; } if(y==j){ muisti++; f.push_back(muisti); } } bool totuus=true; for(int j=0; j<v.size();j++){ if(v[j]==f){ u[j]++; totuus=false; break; } } if(totuus){ v.push_back(f); u.push_back(1); } } int s=0; for(int i=0;i<u.size();i++){ s +=u[i]*(u[i]-1)/2; } cout<<s; }