Submission #372751

#TimeUsernameProblemLanguageResultExecution timeMemory
372751FatihSolakThree Friends (BOI14_friends)C++17
0 / 100
2 ms364 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); int n; cin >> n; string s; cin >> s; int l = (n-1)/2; string ans1="",ans2=""; for(int i=0;i<l;i++){ ans1+=s[i]; } for(int i=l+1;i<n;i++){ ans2+=s[i]; } bool ok1=0,ok2=0; int cnt = 0; for(int i=l;i<n && cnt<l;i++){ if(ans1[cnt] == s[i]){ cnt++; } } ok1 = (cnt == l); cnt = 0; for(int i=0;i<=l && cnt<l;i++){ if(ans2[cnt] == s[i]){ cnt++; } } ok2 = (cnt ==l); if(!ok1 && !ok2){ cout << "NOT POSSIBLE"; return 0; } if(ok1 && ok2 && (ans1 != ans2)){ cout << "NOT UNIQUE"; return 0; } if(ok1){ cout << ans1; return 0; } cout << ans2; }

Compilation message (stderr)

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