답안 #876253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876253 2023-11-21T13:15:55 Z Nurislam Selling RNA Strands (JOI16_selling_rna) C++14
60 / 100
1385 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
/*
<<<<It's never too late for a new beginning in your life>>>>
Today is hard
  tomorrow will worse
  but the day after tomorrow will be the sunshine..
 
HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............
Never give up  */
 
//The most CHALISHKANCHIK
#define int long long int
map<pair<string, string> , int> mp;
void solve(){
	int n, m;
	cin >> n >> m;
	if(n*m <= 1e8+5e7){
		vector<string> v;
		for(int i = 0; i < n; i++){
			string s;
			cin >> s;
			v.push_back(s);
		}
		for(int i = 0; i < m; i++){
			string a, b;
			cin >> a >> b;
			int ans = 0;
			for(int j = 0; j < n; j++){
				if(v[j].size() < a.size() || v[j].size() < b.size())continue;
				if(v[j].substr(0, a.size()) == a && v[j].substr(v[j].size()-b.size()) == b)ans++;
			}
			cout << ans << '\n';
		}
	}
	else {
		for(int i = 0; i < n; i++){
			string s;
			cin >> s;
			for(int k = 0; k < (int)s.size(); k++){
				for(int j = 0; j < (int)s.size(); j++){
					string s1 = s.substr(0, k+1), s2 = s.substr(j);
					mp[{s1, s2}]++;
				}
			}
		}
		for(int i = 0; i < m; i++){
			string a, b;
			cin >> a >> b;
			cout << mp[{a,b}] << '\n';	
		}
	}
}
main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	//~ cin >> t;
	while(t--){
		solve();
	}
}
 
 
 
 
 
 
 
 

Compilation message

selling_rna.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 2556 KB Output is correct
2 Correct 566 ms 2652 KB Output is correct
3 Correct 173 ms 2632 KB Output is correct
4 Correct 234 ms 2716 KB Output is correct
5 Correct 509 ms 1996 KB Output is correct
6 Correct 514 ms 2060 KB Output is correct
7 Correct 412 ms 1884 KB Output is correct
8 Correct 1000 ms 2924 KB Output is correct
9 Correct 866 ms 2672 KB Output is correct
10 Correct 1385 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 580 KB Output is correct
2 Correct 232 ms 6484 KB Output is correct
3 Correct 157 ms 3208 KB Output is correct
4 Correct 45 ms 592 KB Output is correct
5 Correct 200 ms 6440 KB Output is correct
6 Correct 145 ms 3336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 129 ms 2556 KB Output is correct
9 Correct 566 ms 2652 KB Output is correct
10 Correct 173 ms 2632 KB Output is correct
11 Correct 234 ms 2716 KB Output is correct
12 Correct 509 ms 1996 KB Output is correct
13 Correct 514 ms 2060 KB Output is correct
14 Correct 412 ms 1884 KB Output is correct
15 Correct 1000 ms 2924 KB Output is correct
16 Correct 866 ms 2672 KB Output is correct
17 Correct 1385 ms 2688 KB Output is correct
18 Correct 29 ms 580 KB Output is correct
19 Correct 232 ms 6484 KB Output is correct
20 Correct 157 ms 3208 KB Output is correct
21 Correct 45 ms 592 KB Output is correct
22 Correct 200 ms 6440 KB Output is correct
23 Correct 145 ms 3336 KB Output is correct
24 Runtime error 1302 ms 1048576 KB Execution killed with signal 9
25 Halted 0 ms 0 KB -