답안 #83573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83573 2018-11-09T11:41:30 Z heon Mate (COCI18_mate) C++11
0 / 100
2000 ms 2728 KB
#include<bits/stdc++.h>

using namespace std;

const long long MOD = 1000000007;

string s;
int q,qnum;
string qs;

long long povrh(int a,int b){
	long long rt = 1;
	long long lt = 1;
	for(int i = b; i > 0; i--){
		rt *= a;
		rt %= MOD;
		lt *= i;
		lt %= MOD;
		a--;
	}
	long long sol = rt/lt;
	sol %= MOD;
	return sol;
}

int main(){
	cin >> s >> q;
	for(int i = 0; i < q; i++){
		cin >> qnum >> qs;
		long long sol = 0;
		for(int j = 0; j < s.size()-1; j++){
			if(s[j] != qs[0]) continue;
			for(int k = j+1; k < s.size(); k++){
				if(s[k] != qs[1]) continue;
				if(j >= qnum-2) sol += povrh(j,qnum-2);
			}
		}
		sol %= MOD;
		cout << sol << endl;
	}
}

Compilation message

mate.cpp: In function 'int main()':
mate.cpp:31:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < s.size()-1; j++){
                  ~~^~~~~~~~~~~~
mate.cpp:33:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k = j+1; k < s.size(); k++){
                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 376 KB Output isn't correct
2 Incorrect 43 ms 376 KB Output isn't correct
3 Incorrect 46 ms 464 KB Output isn't correct
4 Incorrect 77 ms 464 KB Output isn't correct
5 Incorrect 778 ms 1388 KB Output isn't correct
6 Incorrect 841 ms 2100 KB Output isn't correct
7 Incorrect 688 ms 2360 KB Output isn't correct
8 Incorrect 646 ms 2728 KB Output isn't correct
9 Execution timed out 2059 ms 2728 KB Time limit exceeded
10 Execution timed out 2053 ms 2728 KB Time limit exceeded