제출 #748432

#제출 시각아이디문제언어결과실행 시간메모리
748432mariowong세 명의 친구들 (BOI14_friends)C++14
0 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; int n,pos1,pos2,ct,ans; string s,t,r,anss; bool ok; int main(){ ios::sync_with_stdio(false); scanf("%d%s",&n,s); if (n%2 == 0){ cout << "NOT POSSIBLE\n"; return 0; } for (int i=1;i<=n/2;i++){ t+=s[i]; } for (int i=n/2+1;i<n;i++){ r+=s[i]; } for (int i=0;i<n/2;i++){ if (t[i] == r[i]) ct++; } for (int i=0;i<n;i++){ if (ct == n/2){ ans++; if (ans > 1 && t != anss) ok=true; else if (ans == 1) anss=t; } if (pos1 != n/2){ if (t[pos1] == r[pos1]) ct--; t[pos1]=s[i]; if (t[pos1] == r[pos1]) ct++; pos1++; } else { if (t[pos2] == r[pos2]) ct--; r[pos2]=s[i]; if (t[pos2] == r[pos2]) ct++; pos2++; } } if (ct == n/2){ ans++; if (ans > 1 && t != anss) ok=true; else if (ans == 1) anss=t; } if (ok) printf("NOT UNIQUE\n"); else if (ans == 0) printf("NOT POSSIBLE\n"); else printf("%d\n",anss); return 0; }

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

friends.cpp: In function 'int main()':
friends.cpp:9:14: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'std::string' {aka 'std::__cxx11::basic_string<char>'} [-Wformat=]
    9 |    scanf("%d%s",&n,s);
      |             ~^      ~
      |              |      |
      |              char*  std::string {aka std::__cxx11::basic_string<char>}
friends.cpp:61:16: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::string' {aka 'std::__cxx11::basic_string<char>'} [-Wformat=]
   61 |  else printf("%d\n",anss);
      |               ~^        ~
      |                |        |
      |                int      std::string {aka std::__cxx11::basic_string<char>}
friends.cpp:9:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |    scanf("%d%s",&n,s);
      |    ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...