CSES - Datatähti 2020 alku - Results
Submission details
Task:Merkkijonot
Sender:Juho
Submission time:2019-10-04 08:40:49 +0300
Language:C++11
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:6:5: error: 't' was not declared in this scope
     t[n];
     ^
input/code.cpp:10:17: error: expected initializer before '>>' token
         string x>>t[i];
                 ^~
input/code.cpp:18:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(short j=0;j<x.size();j++){
                       ~^~~~~~~~~
input/code.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<v.size();j++){
                     ~^~~~~~~~~
input/code.cpp:40: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;
    t[n];
    vector<long long>v;
    vector<long long>u;
    for(int i=0;i<n;i++){
        string x>>t[i];
    }
    for(int i=0;i<n;i++){
        string x = t[i];
        unordered_map<char,char>m;
        char muisti='A';
        long long y=0;
        long long potenssi =1;
        for(short j=0;j<x.size();j++){
            if(!(m.count(x[j]))){
                m[x[j]]=muisti;
                muisti++;
            }
            y = (y+potenssi*(long long)m[x[j]])%1833728171113LL;
            potenssi = (potenssi*281)%1833728171113LL;
        }
        bool totuus = true;
        for(int j=0;j<v.size();j++){
            if(v[j]==y){
                totuus=false;
                u[j]++;
                break;
            }
        }
        if(totuus){
            v.push_back(y);
            u.push_back(1);
        }
    }
    long long s = 0;
    for(int i=0;i<u.size();i++){
        s += u[i]*(u[i]-1)/2;
    }
    cout<<s;
}