답안 #1067792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067792 2024-08-21T03:21:10 Z tnkhuyen Selling RNA Strands (JOI16_selling_rna) C++14
10 / 100
1500 ms 9552 KB
#include<bits/stdc++.h>
#define ll long long
#define FOR(i,a,b) for(ll i=(ll)a; i<=(ll)b; i++)
#define ROF(i,b,a) for(ll i=(ll)b; i>=(ll)a; i--)

using namespace std;

const ll maxn = 1e5 + 1;

ll n, m;
string a[maxn], x, y;

void sub1(){
	ll co = 0, id;
	bool kt1, kt2;
	FOR(i,1,m){
		cin >> x >> y;
	//	if (i == 1) continue;
	//	cout << x << " " << y << endl;
		co = 0;
		FOR(j,1,n){
			kt1 = true; kt2 = true;
			id = 0;
			FOR(k,0,x.size()-1){
				if (a[j][id] != x[k]){
			//		cout << "hi" << " " << a[j][k] << " " << x[k] << endl;
		//			cout << 1 << " " << j << " " << k << " " << a[id][k] << " " << x[k] << endl;
					kt1 = false; 
					break;
				}
				id++;
			}
			
			id = a[j].size()-1;
			
			ROF(k,y.size()-1,0){
				if (a[j][id] !=y[k]){
				//	cout << 2 << " " << j << " " << k << " " << a[j][id] << " " << y[k]  << endl;
					kt2 = false;
					break;
				}
				id--;
			}
		//	cout << i << " " << j << " " << kt1 << " " << kt2 << endl;
			if (kt1 == true && kt2 == true){
				co++;
			}
		}
		cout << co << "\n";
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> m;
	FOR(i,1,n){
		cin >> a[i];
	}
//	x = "aaaa";
//	cout << "hi" << " " << x[x.size()] << endl;
	
	sub1();
	
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3420 KB Output is correct
2 Correct 2 ms 3592 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 2 ms 3420 KB Output is correct
5 Correct 2 ms 3420 KB Output is correct
6 Correct 2 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 876 ms 9552 KB Output is correct
2 Execution timed out 1565 ms 9300 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1521 ms 3928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3420 KB Output is correct
2 Correct 2 ms 3592 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 2 ms 3420 KB Output is correct
5 Correct 2 ms 3420 KB Output is correct
6 Correct 2 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 876 ms 9552 KB Output is correct
9 Execution timed out 1565 ms 9300 KB Time limit exceeded
10 Halted 0 ms 0 KB -