Submission #105576

# Submission time Handle Problem Language Result Execution time Memory
105576 2019-04-13T17:33:44 Z Leonardo_Paes Three Friends (BOI14_friends) C++11
0 / 100
500 ms 8632 KB
#include <bits/stdc++.h>

using namespace std;

int mark[27];

int main(){

  map<string, int> m;

	int n;

	cin >> n;


		string t;

		cin >> t;

		for(int i=0; i<n; i++){
			mark[t[i]-'A']++;
		}

  	if(n%2==0){
		cout << "NOT POSSIBLE" << endl;
    return 0;
	}

		int x=-1;

    bool resp=true;

		for(int i=0; i<=26; i++){
			if(mark[i]%2==1){
        if(x!=-1)resp=false;
				x=i;
			}
		}
    if(resp==false){
      cout << "NOT POSSIBLE" << endl;
      return 0;
    }
    string y;
    string p;
    for(int i=0; i<n; i++){

      if(t[i]-'A'==x){
              int u=0;
      string h;
        for(int j=0; j<n; j++){
          if(i!=j){
            h+=t[j];
            u++;
          }
          if(u==(n-1)/2)break;
        }
        string q;

      for(int i=u+1; i<n; i++){
        q+=t[i];
      }
      if(q==h and m.find(q)==m.end()){
        y=q;
        m[q]=2;
      }
      else{
          p="NOT UNIQUE\n";
      }
      }
    }
    if(resp==false){
      cout << "NOT POSSIBLE\n";
    }
    else if(p=="NOT UNIQUE\n"){
      cout << p;
    }
    else{
      cout << y << endl;
    }
	

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 8632 KB Time limit exceeded
2 Halted 0 ms 0 KB -