Submission #85839

# Submission time Handle Problem Language Result Execution time Memory
85839 2018-11-21T22:05:17 Z kraljlavova1 Mate (COCI18_mate) C++11
0 / 100
1600 ms 70328 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
const int MOD=1e9+7,MAXQ=500010,MAXS=2010;
string s,xy[MAXQ];
llint sol[MAXS][26][26];
int q,len,l[MAXQ];
map<string,vector<int> >mp;
int bio[MAXS];
llint povrh[MAXS][MAXS];
void pov(){
	povrh[0][0]=1;
	for(int i=1;i<MAXS;i++){
		for(int j=0;j<MAXS;j++){
			if(j==0){
				povrh[i][j]=1;
				continue;
			}
			povrh[i][j]=povrh[i-1][j]+povrh[i-1][j-1];
			povrh[i][j]%=MOD;
		}
	}
}
int main(){
	pov();
	cin>>s;
	cin>>q;
	len=s.length();
	for(int i=0;i<q;i++){
		cin>>l[i]>>xy[i];
		if(!bio[l[i]]){
			mp[xy[i]].push_back(l[i]);
			bio[l[i]]=1;
		}
	}
	for(int i=0;i<len;i++){
		for(int j=i+1;j<len;j++){
			string a="";
			a+=s[i];
			a+=s[j];
			for(int k=0;k<mp[a].size();k++){
				int d=mp[a][k];
				sol[d][a[0]-'a'][a[1]-'a']+=povrh[i][d-2];
				sol[d][a[0]-'a'][a[1]-'a']%=MOD;
			}
		}
	}
	for(int i=0;i<q;i++){
		cout<<sol[l[i]][xy[i][0]-'a'][xy[i][1]-'a']<<"\n";
	}
	return 0;
}

Compilation message

mate.cpp: In function 'int main()':
mate.cpp:41:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k=0;k<mp[a].size();k++){
                ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 48120 KB Output isn't correct
2 Incorrect 58 ms 48252 KB Output isn't correct
3 Incorrect 58 ms 48340 KB Output isn't correct
4 Incorrect 67 ms 48784 KB Output isn't correct
5 Incorrect 135 ms 50756 KB Output isn't correct
6 Incorrect 134 ms 51976 KB Output isn't correct
7 Incorrect 160 ms 52488 KB Output isn't correct
8 Incorrect 108 ms 53028 KB Output isn't correct
9 Incorrect 1600 ms 66176 KB Output isn't correct
10 Incorrect 1580 ms 70328 KB Output isn't correct