Submission #370641

# Submission time Handle Problem Language Result Execution time Memory
370641 2021-02-24T11:04:32 Z FatihSolak Rima (COCI17_rima) C++17
0 / 140
34 ms 32364 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;
}

Compilation message

rima.cpp: In function 'int main()':
rima.cpp:10:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  freopen("in.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
rima.cpp:11:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  freopen("out.txt","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 32364 KB Execution killed with signal 6
2 Runtime error 33 ms 32364 KB Execution killed with signal 6
3 Runtime error 34 ms 32364 KB Execution killed with signal 6
4 Runtime error 33 ms 32364 KB Execution killed with signal 6
5 Runtime error 33 ms 32364 KB Execution killed with signal 6
6 Runtime error 33 ms 32364 KB Execution killed with signal 6
7 Runtime error 32 ms 32364 KB Execution killed with signal 6
8 Runtime error 32 ms 32364 KB Execution killed with signal 6
9 Runtime error 33 ms 32364 KB Execution killed with signal 6
10 Runtime error 33 ms 32364 KB Execution killed with signal 6