답안 #74665

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74665 2018-09-06T00:20:18 Z Genezio Selling RNA Strands (JOI16_selling_rna) C++14
10 / 100
1500 ms 1049600 KB
#include<bits/stdc++.h>

using namespace std;

// SUBTASK - 25 PTS

const int N = 100010;

map<int,string> pre[N];
map<int,string> suf[N];
int tam[N];

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

	int n,m;
	string s,p,q;
	cin>>n>>m;
	for(int i=0;i<n;i++) {
		cin>>s;
		tam[i]=s.size();
		string auxp;
		string auxs;
		for(int j=0;j<s.size();j++) {
			auxp+=s[j];
			auxs=s.substr(tam[i]-1-j,tam[i]);
			//cout<<i<<" "<<j<<" "<<auxp<<" "<<auxs<<"\n";
			pre[j+1][i]=auxp;
			suf[j+1][i]=auxs;
		}
	}
	for(int i=0;i<m;i++) {
		cin>>p>>q;
		int ans=0;
		//cout<<i<<" "<<p<<" "<<q<<"\n";
		for(int j=0;j<n;j++) {
			if(p.size()>tam[j]||q.size()>tam[j]) continue;
			//cout<<j<<" "<<pre[p.size()][j]<<" "<<suf[q.size()][j]<<"\n";
			if(pre[p.size()][j]==p&&suf[q.size()][j]==q) ans++;
		}
		cout<<ans<<"\n";
	}
}

Compilation message

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<s.size();j++) {
               ~^~~~~~~~~
selling_rna.cpp:38:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(p.size()>tam[j]||q.size()>tam[j]) continue;
       ~~~~~~~~^~~~~~~
selling_rna.cpp:38:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(p.size()>tam[j]||q.size()>tam[j]) continue;
                        ~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 9720 KB Output is correct
2 Correct 10 ms 9980 KB Output is correct
3 Correct 10 ms 9980 KB Output is correct
4 Correct 10 ms 9980 KB Output is correct
5 Correct 10 ms 9980 KB Output is correct
6 Correct 11 ms 9980 KB Output is correct
7 Correct 14 ms 9988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1388 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1563 ms 1049600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 9720 KB Output is correct
2 Correct 10 ms 9980 KB Output is correct
3 Correct 10 ms 9980 KB Output is correct
4 Correct 10 ms 9980 KB Output is correct
5 Correct 10 ms 9980 KB Output is correct
6 Correct 11 ms 9980 KB Output is correct
7 Correct 14 ms 9988 KB Output is correct
8 Runtime error 1388 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Halted 0 ms 0 KB -