| Task: | Ruudukko |
| Sender: | Juho |
| Submission time: | 2019-10-05 18:56:12 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.01 s | details |
| #2 | WRONG ANSWER | 0.01 s | details |
| #3 | WRONG ANSWER | 0.01 s | details |
| #4 | WRONG ANSWER | 0.01 s | details |
| #5 | WRONG ANSWER | 0.01 s | details |
| #6 | WRONG ANSWER | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:14:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<z.size();j++){
~^~~~~~~~~
input/code.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<x.size();j++){
~^~~~~~~~~
input/code.cpp:65:19: 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<long long>v;
vector<int>u;
string z;
cin>>z;
unordered_map<char,char> mz;
long long yz=0;
long long potenssiz=1;
char muistiz = 'A';
for(int j=0;j<z.size();j++){
if(!mz.count(z[j])){
mz[z[j]]=muistiz;
muistiz++;
}
potenssiz = (potenssiz*723)%1127368712672817;
yz = (yz+((long long)mz[z[j]])*potenssiz)%1127368712672817;
}
v.push_back(yz);
u.push_back(1);
for(int i=0;i<n-1;i++){
string x;
cin>>x;
unordered_map<char,char> m;
long long y=0;
char muisti = 'A';
long long potenssi =1;
for(int j=0;j<x.size();j++){
if(!m.count(x[j])){
m[x[j]]=muisti;
muisti++;
}
potenssi = (potenssi*723)%1127368712672817;
y = (y+((long long)m[x[j]])*potenssi)%1127368712672817;
}
int ylaraja = u.size()-1;
int alaraja = 0;
while(alaraja<ylaraja-1){
if(v[(alaraja+ylaraja)/2]<y){
alaraja = (alaraja+ylaraja)/2;
}else{
ylaraja = (alaraja+ylaraja)/2;
}
}
if(v[alaraja]==y){
u[alaraja]++;
}else if(v[ylaraja]==y){
u[ylaraja]++;
}else if(y<v[alaraja]){
v.insert(v.begin()+0, y);
u.insert(u.begin()+0, 1);
}else if(v[ylaraja]<y){
v.push_back(y);
u.push_back(1);
}else{
v.insert(v.begin()+ylaraja, y);
u.insert(u.begin()+ylaraja, 1);
}
}
long long s = 0LL;
for(int i=0; i<u.size();i++){
s = s+u[i]*(u[i]-1)/2;
}
cout<<s;
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 0 |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 2 |
| correct output |
|---|
| 1 2 2 1 |
| user output |
|---|
| 1 |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 5 |
| correct output |
|---|
| 1 2 3 4 5 2 1 4 3 6 3 4 1 2 7 4 3 2 1 8 5 6 7 8 1 |
| user output |
|---|
| 10 |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 42 |
| correct output |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| user output |
|---|
| 861 |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 99 |
| correct output |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| user output |
|---|
| 4851 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 100 |
| correct output |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| user output |
|---|
| 4950 |
