답안 #370642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
370642 2021-02-24T11:05:03 Z FatihSolak Rima (COCI17_rima) C++17
56 / 140
1000 ms 71460 KB
#include <bits/stdc++.h>
#define N 500005
using namespace std;
string s[N];
map<string,int> mp;
map<string,int> mp2;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s[i];
		string t = s[i];
		reverse(t.begin(), t.end());
		mp[t]++;
		t.pop_back();
		mp2[t]++;
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		string c = s[i];
		reverse(c.begin(), c.end());
		string t = c;
		c.pop_back();
		int sum = 0;
		while(t.size()){
			sum += mp2[c];
			c.pop_back();
			t.pop_back();
			if(!mp[t]){
				break;
			}
		}
		ans = max(ans,sum);
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 15980 KB Output is correct
2 Correct 11 ms 15980 KB Output is correct
3 Correct 12 ms 15980 KB Output is correct
4 Execution timed out 1087 ms 71460 KB Time limit exceeded
5 Correct 778 ms 28012 KB Output is correct
6 Incorrect 27 ms 19292 KB Output isn't correct
7 Incorrect 25 ms 18916 KB Output isn't correct
8 Incorrect 25 ms 18724 KB Output isn't correct
9 Incorrect 184 ms 28928 KB Output isn't correct
10 Incorrect 29 ms 18760 KB Output isn't correct