제출 #493984

#제출 시각아이디문제언어결과실행 시간메모리
493984goodluck2020세 명의 친구들 (BOI14_friends)C++14
0 / 100
29 ms26408 KiB
#include <bits/stdc++.h> #define task "friends" using namespace std; const int N = 1e6 + 10; int c, n, m, A[N], B[N], ans, res, tmp; bool L[N], R[N]; string S; int CALC() { L[0] = 1; R[n + 1] = 1; for(int i = 1; i <= n; i++) L[i] = min(L[i-1], (A[i] == B[i])); for(int i = n; i >= 1; i--) R[i] = min(R[i+1], (A[i] == B[i - 1])); for(int i = 1; i < n; i++) if(L[i-1] && R[i+1]) { ans++; res = tmp + i; } } void TruyVet(int k) { if(k > c/2) for(int i = 0; i < c/2; i++) cout << S[i]; else for(int i = c/2 + 1; i < c; i++) cout << S[i]; } int main() { if(fopen(task ".inp","r")) { freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> c >> S; if(c % 2 == 0) { cout << "NOT POSSIBLE"; return 0; } for(int i = 0; i <= c/2; i++) A[++n] = S[i] - 'A'; for(int i = c/2 + 1; i < c; i++) B[++m] = S[i] - 'A'; ans += CALC(); for(int i = 0; i < c/2; i++) B[++m] = S[i] - 'A'; for(int i = c/2; i < c; i++) A[++n] = S[i] - 'A'; tmp = c/2; ans += CALC(); if(ans == 1) TruyVet(res); else if(ans > 1) cout << "NOT UNIQUE"; else cout << "NOT POSSIBLE"; }

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

friends.cpp: In function 'int CALC()':
friends.cpp:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }
      | ^
friends.cpp: In function 'int main()':
friends.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen(task ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
friends.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen(task ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...