제출 #656202

#제출 시각아이디문제언어결과실행 시간메모리
656202600Mihnea세 명의 친구들 (BOI14_friends)C++17
35 / 100
1088 ms13048 KiB
bool home = 0;
bool verbose = 1;

#include <bits/stdc++.h>

using namespace std;

int main() {

  if (!home) {
    verbose = 0;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  if (home) {
    verbose = 1;
    freopen ("___input___.txt", "r", stdin);
  }

  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << "NOT POSSIBLE\n";
    return 0;
  }
  string s;
  cin >> s;
  assert((int) s.size() == n);
  int half = (n - 1) / 2;
  string pref(s.begin(), s.begin() + half);
  string suf(s.end() - half, s.end());
  int cnt = 0;
  string goods;
  vector<string> trs;
  if (pref == suf) {
    trs = {pref + pref};
  } else {
    trs = {pref + pref, suf + suf};
  }
  for (auto &tr : trs) {
    assert((int) tr.size() == n - 1);
    bool ok = 0;
    for (int skip = 0; skip < n; skip++) {
      string lol = string(s.begin(), s.begin() + skip) + string(s.begin() + skip + 1, s.end());
      assert((int) lol.size() == n - 1);
      ok |= (lol == tr);
    }
    if (ok) {
      cnt++;
      goods = tr;
    }
  }
  if (cnt == 0) {
    cout << "NOT POSSIBLE\n";
    return 0;
  }
  if (cnt == 2) {
    cout << "NOT UNIQUE\n";
    return 0;
  }
  assert(cnt == 1);
  goods.resize(half);
  cout << goods << "\n";
  return 0;
}

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

friends.cpp: In function 'int main()':
friends.cpp:18:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen ("___input___.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...