답안 #111134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111134 2019-05-13T19:04:48 Z heon Mate (COCI18_mate) C++17
0 / 100
2000 ms 1776 KB
#include<iostream>

using namespace std;
#define int long long

const int MOD = 1000000007;

string s;
int q,qnum;
string qs;

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

signed main(){
	cin >> s >> q;
	for(int i = 0; i < q; i++){
		cin >> qnum >> qs;
		int 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:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < s.size()-1; j++){
                  ~~^~~~~~~~~~~~
mate.cpp:34:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k = j+1; k < s.size(); k++){
                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 760 KB Output isn't correct
2 Incorrect 36 ms 512 KB Output isn't correct
3 Incorrect 43 ms 512 KB Output isn't correct
4 Incorrect 69 ms 640 KB Output isn't correct
5 Incorrect 643 ms 1656 KB Output isn't correct
6 Incorrect 723 ms 1776 KB Output isn't correct
7 Incorrect 563 ms 1528 KB Output isn't correct
8 Incorrect 537 ms 1408 KB Output isn't correct
9 Execution timed out 2041 ms 504 KB Time limit exceeded
10 Execution timed out 2048 ms 384 KB Time limit exceeded