제출 #105807

#제출 시각아이디문제언어결과실행 시간메모리
105807xiaowuc1세 명의 친구들 (BOI14_friends)C++14
0 / 100
17 ms10368 KiB
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

bool can(string a, string b) {
	int aIdx = 0;
	for(int i = 0; i < b.size() && aIdx < a.size(); i++) {
		if(b[i] == a[aIdx]) aIdx++;
	}
	return aIdx == a.size();
}

void solve() {
	int n;
	string s;
	cin >> n >> s;
	set<string> ret;
	if(can(s.substr(0, n), s.substr(n))) {
		ret.insert(s.substr(0, n));
	}
	if(can(s.substr(n+1), s.substr(0, n+1))) {
		ret.insert(s.substr(n+1));
	}
	if(ret.size() > 1) cout << "NOT UNIQUE\n";
	else if(ret.empty()) cout << "NOT POSSIBLE\n";
	else cout << *ret.begin() << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
	/*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
	*/
	solve();
}

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp: In function 'bool can(std::__cxx11::string, std::__cxx11::string)':
friends.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < b.size() && aIdx < a.size(); i++) {
                 ~~^~~~~~~~~~
friends.cpp:21:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < b.size() && aIdx < a.size(); i++) {
                                 ~~~~~^~~~~~~~~~
friends.cpp:24:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  return aIdx == a.size();
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...