Submission #1109351

#TimeUsernameProblemLanguageResultExecution timeMemory
1109351NeltThree Friends (BOI14_friends)C++17
0 / 100
12 ms7412 KiB
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string a = s.substr(0, n >> 1), b = s.substr(n - (n >> 1));
    ll ptr = 0, ptr1 = 0;
    for (ll i = (n >> 1); i < n; i++)
        if (ptr < a.size() and s[i] == a[ptr]) ptr++;
    for (ll i = 0; i < n - (n >> 1); i++) if (ptr1 < b.size() and s[i] == b[ptr1]) ptr1++;
    if (ptr < a.size() and ptr1 < b.size()) cout << "NOT POSSIBLE\n";
    else if (ptr == a.size() and ptr1 == b.size()) cout << "NOT UNIQUE\n";
    else if (ptr == a.size()) cout << a << endl;
    else cout << b << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // precomp();
    // cin >> t;
    for (ll i = 1; i <= t; i++)
        solve();
    cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}

Compilation message (stderr)

friends.cpp: In function 'void solve()':
friends.cpp:16:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         if (ptr < a.size() and s[i] == a[ptr]) ptr++;
      |             ~~~~^~~~~~~~~~
friends.cpp:17:52: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (ll i = 0; i < n - (n >> 1); i++) if (ptr1 < b.size() and s[i] == b[ptr1]) ptr1++;
      |                                               ~~~~~^~~~~~~~~~
friends.cpp:18:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     if (ptr < a.size() and ptr1 < b.size()) cout << "NOT POSSIBLE\n";
      |         ~~~~^~~~~~~~~~
friends.cpp:18:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     if (ptr < a.size() and ptr1 < b.size()) cout << "NOT POSSIBLE\n";
      |                            ~~~~~^~~~~~~~~~
friends.cpp:19:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     else if (ptr == a.size() and ptr1 == b.size()) cout << "NOT UNIQUE\n";
      |              ~~~~^~~~~~~~~~~
friends.cpp:19:39: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     else if (ptr == a.size() and ptr1 == b.size()) cout << "NOT UNIQUE\n";
      |                                  ~~~~~^~~~~~~~~~~
friends.cpp:20:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     else if (ptr == a.size()) cout << a << endl;
      |              ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...