답안 #282609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282609 2020-08-24T15:45:47 Z limabeans Selling RNA Strands (JOI16_selling_rna) C++17
10 / 100
1500 ms 37880 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


int n, m;
string s[maxn];



bool match(string s, string pre, string suf) {
    if (pre.size() > s.size()) return false;
    if (suf.size() > s.size()) return false;
    int n = s.length();
    for (int i=0; i<(int)pre.size(); i++) {
	if (s[i]!=pre[i]) return false;
    }
    
    for (int i=0; i<(int)suf.size(); i++) {
	if (suf[(int)suf.size()-i-1] != s[n-1-i]) return false;
    }
    return true;
}

int solve(string p, string q) {
    int res = 0;
    for (int i=0; i<n; i++) {
	res += match(s[i], p, q);
    }

    return res;
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>m;
    for (int i=0; i<n; i++) {
	cin>>s[i];
    }

    for (int i=0; i<m; i++) {
	string p, q;
	cin>>p>>q;
	cout<<solve(p,q)<<"\n";
    }
    
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 31616 KB Output is correct
2 Correct 21 ms 31616 KB Output is correct
3 Correct 21 ms 31616 KB Output is correct
4 Correct 22 ms 31616 KB Output is correct
5 Correct 20 ms 31612 KB Output is correct
6 Correct 20 ms 31616 KB Output is correct
7 Correct 21 ms 31616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1587 ms 37880 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1590 ms 32088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 31616 KB Output is correct
2 Correct 21 ms 31616 KB Output is correct
3 Correct 21 ms 31616 KB Output is correct
4 Correct 22 ms 31616 KB Output is correct
5 Correct 20 ms 31612 KB Output is correct
6 Correct 20 ms 31616 KB Output is correct
7 Correct 21 ms 31616 KB Output is correct
8 Execution timed out 1587 ms 37880 KB Time limit exceeded
9 Halted 0 ms 0 KB -