#include <bits/stdc++.h>
using namespace std;
vector<pair<string, int> > *prv;
int nof(string sstr){
int l = -1;
int h = prv->size();
while(h-1>l){
int mid = (h+l)/2;
pair<string, int> x = (*prv)[mid];
if(x.first == sstr){
return x.second;
}else if(x.first < sstr){
l = mid;
}else{
h = mid;
}
}
return 0;
}
//C:\Users\user\Documents\trener.cpp|9|error: conversion from 'std::vector<std::pair<std::__cxx11::basic_string<char>, int> >*' to non-scalar type 'std::pair<std::__cxx11::basic_string<char>, int>' requested|
int main(){
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
prv = new vector<pair<string, int> >();
for(int i = 0; i < k; i++){
string ns;
cin >> ns;
prv->push_back(make_pair(ns, 1));
}
sort(prv->begin(), prv->end());
for(int i = 1; i < n; i++){
string ns;
vector<pair<string, int> > *cur;
cur = new vector<pair<string, int> >();
for(int l = 0; l < k; l++){
cin >> ns;
char scrafter[i+1];
scrafter[i] = '\0';
for(int j = 0; j < i; j++){
scrafter[j] = ns[j];
}
string fs, ss;
fs = scrafter;
int nmatch = nof(fs);
for(int j = 0; j < i; j++){
scrafter[j] = ns[j+1];
}
ss = scrafter;
if(ss != fs){
nmatch += nof(ss);
nmatch %= 1000000007;
}
cur->push_back(make_pair(ns,nmatch));
}
prv = cur;
}
int tal = 0;
for(int i = 0; i < k; i++){
tal += (*prv)[i].second;
tal %= 1000000007;
}
cout << tal;
}
/*
3 2
a b
ab bd
abc abd
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |