제출 #398734

#제출 시각아이디문제언어결과실행 시간메모리
398734YaserFaisal세 명의 친구들 (BOI14_friends)C++14
0 / 100
1093 ms20488 KiB
#include <bits/stdc++.h> using namespace std ; //#define int long long int MOD = 1e9+7 ; int freq[200] ; vector < int > v[200] ; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n ; cin >> n ; string s ; cin >> s ; for ( int i = 0 ; i < n ; i++ ) { freq[s[i]]++ ; v[s[i]].push_back(i) ; } char x ; int odd = 0 ; for ( int i = 'A' ; i <= 'Z' ; i++ ) { if ( freq[i] % 2 ) { odd++ ; x = i ; } } if ( odd > 1 || n % 2 == 0 ) { cout << "NOT POSSIBLE\n" ; return 0 ; } string ans = "-" ; for ( int i = 0 ; i < v[x].size() ; i++ ) { string g = s ; g.erase(g.begin()+v[x][i]) ; string a = (g.substr(0,n/2)) , b = (g.substr(n/2,n/2)) ; if ( a == b ) { if ( ans != "-" ) { cout << "NOT UNIQUE\n" ; return 0 ; } ans = a ; } } if ( ans == "-" ) ans = "NOT POSSIBLE" ; cout << ans << "\n" ; }

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

friends.cpp: In function 'int32_t main()':
friends.cpp:17:18: warning: array subscript has type 'char' [-Wchar-subscripts]
   17 |         freq[s[i]]++ ;
      |                  ^
friends.cpp:18:15: warning: array subscript has type 'char' [-Wchar-subscripts]
   18 |         v[s[i]].push_back(i) ;
      |               ^
friends.cpp:36:29: warning: array subscript has type 'char' [-Wchar-subscripts]
   36 |     for ( int i = 0 ; i < v[x].size() ; i++ )
      |                             ^
friends.cpp:36:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for ( int i = 0 ; i < v[x].size() ; i++ )
      |                       ~~^~~~~~~~~~~~~
friends.cpp:39:29: warning: array subscript has type 'char' [-Wchar-subscripts]
   39 |         g.erase(g.begin()+v[x][i]) ;
      |                             ^
friends.cpp:20:10: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |     char x ;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...