제출 #398769

#제출 시각아이디문제언어결과실행 시간메모리
398769katwamiaw세 명의 친구들 (BOI14_friends)C++14
35 / 100
1092 ms3052 KiB
#include<bits/stdc++.h> using namespace std ; //it ain't much but it's honest work int a[27] ; char c[27] ; vector<int>v ; vector<string>q ; set<string>z ; int n ; string s ; void something(int x){ string ans ; //cout << x << endl ; for(int i=0 ; i<n/2 ; i++){ //if(i==x) continue ; int r=i , t=(n/2)+i ; if(r>=x) r++ ; if(t>=x) t++ ; if(s[r]==s[t]){ ans+=s[r] ; //cout << 8 ; } else{ break ; } } if(ans.size()==n/2){ q.push_back(ans) ; z.insert(ans) ; } if(z.size()>1){ cout << "NOT UNIQUE" ; exit(0) ; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> n >> s ; for(int i=0 ; i<n ; i++){ a[(s[i]-'0')-17]++ ; } int k=-1 , g=0 ; for(int i=0 ; i<26 ; i++){ if(a[i]%2){ k=i ; g++ ; } } if(g>1||k==-1){ cout << "NOT POSSIBLE" ; return 0 ; } for(int i=0 ; i<n ; i++){ if(((s[i]-'0')-17)==k){ v.push_back(i) ; //cout << s[i] ; } } for(int i=0 ; i<v.size() ; i++){ something(v[i]) ; } if(z.size()==0){ cout << "NOT POSSIBLE" ; } else if(z.size()>1){ cout << "NOT UNIQUE" ; } else{ cout << q[0] ; } }

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

friends.cpp: In function 'void something(int)':
friends.cpp:30:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |     if(ans.size()==n/2){
      |        ~~~~~~~~~~^~~~~
friends.cpp: In function 'int main()':
friends.cpp:66:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for(int i=0 ; i<v.size() ; i++){
      |                   ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...