제출 #845324

#제출 시각아이디문제언어결과실행 시간메모리
845324vjudge1세 명의 친구들 (BOI14_friends)C++17
100 / 100
11 ms10044 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; const int N = 1 << 20; const int INF = INT_MAX; const int mod = 1e9+7; int n; string a1,b1,s; set<string> ans; bool check(string a, string b) { for(int i = 0, j = 0, cnt = 0; i < a.size() ; i++) { if(a[i] != b[j] && cnt == 0) { cnt++; i--; } else if(a[i] != b[j]) { return false; } j++; } return true; } signed main() { if (fopen("solve.inp", "r")) { freopen("solve.inp", "r", stdin); freopen("solve.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> s; if(n%2 == 0) { cout << "NOT POSSIBLE"; return 0; } a1 = s.substr(0,n/2); b1 = s.substr(n/2); if(check(a1,b1)) { ans.insert(a1); } a1 = s.substr(n/2+1); b1 = s.substr(0,n/2+1); if(check(a1,b1)) { ans.insert(a1); } if(ans.size() == 0) { cout << "NOT POSSIBLE"; } else if(ans.size() > 1) { cout << "NOT UNIQUE"; } else { cout << (*ans.begin()); } return 0; }

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

friends.cpp: In function 'bool check(std::string, std::string)':
friends.cpp:16:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0, j = 0, cnt = 0; i < a.size() ; i++) {
      |                                    ~~^~~~~~~~~~
friends.cpp: In function 'int main()':
friends.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen("solve.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
friends.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen("solve.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...