제출 #653137

#제출 시각아이디문제언어결과실행 시간메모리
653137aryan12세 명의 친구들 (BOI14_friends)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; string s,t; int l,r,i,p,n,f,g; bool f,g; bool check() { p = 0; for(i = l; i <= r; i++) { if(p != t.size() && t[p] == s[i]) { p++; } } return (p == t.size()); } int32_t main() { cin >> n; cin >> s; if(n % 2 == 0) { cout << "NOT POSSIBLE\n"; return; } t = s.substr(0, n / 2); l = n / 2; r = n - 1; f = check(); t = s.substr(n - n / 2, n / 2); l = 0; r = n / 2; g = check(); if(!f && !g) { cout << "NOT POSSIBLE\n"; } else if(f && g && s.substr(0, n / 2) != s.substr(n - n / 2, n / 2)) { cout << "NOT UNIQUE\n"; } else if(f) { cout << s.substr(0, n / 2) << "\n"; } else { cout << s.substr(n - n / 2, n / 2) << "\n"; } }

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

friends.cpp:5:6: error: conflicting declaration 'bool f'
    5 | bool f,g;
      |      ^
friends.cpp:4:15: note: previous declaration as 'int f'
    4 | int l,r,i,p,n,f,g;
      |               ^
friends.cpp:5:8: error: conflicting declaration 'bool g'
    5 | bool f,g;
      |        ^
friends.cpp:4:17: note: previous declaration as 'int g'
    4 | int l,r,i,p,n,f,g;
      |                 ^
friends.cpp: In function 'bool check()':
friends.cpp:10:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         if(p != t.size() && t[p] == s[i]) {
      |            ~~^~~~~~~~~~~
friends.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     return (p == t.size());
      |             ~~^~~~~~~~~~~
friends.cpp: In function 'int32_t main()':
friends.cpp:22:9: error: return-statement with no value, in function returning 'int32_t' {aka 'int'} [-fpermissive]
   22 |         return;
      |         ^~~~~~