제출 #89356

#제출 시각아이디문제언어결과실행 시간메모리
89356Tieuphong세 명의 친구들 (BOI14_friends)C++11
0 / 100
23 ms19328 KiB
/***************************************************************************/ /********************** LANG TU HAO HOA **********************************/ /***************************************************************************/ #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) #define pii pair<int, int> #define sz(x) ((int) x.size()) #define PB push_back #define PF push_front #define MP make_pair #define ll long long #define F first #define S second #define maxc 1000000007 #define MOD 1000000007 #define base 107 #define eps 1e-6 #define pi acos(-1) #define N 2000006 #define task "" #define remain(x) ((x > MOD) ? (x - MOD) : x) using namespace std; int n; string s, ans[3]; int dem = 0; string Check(int st1, int st2, int id) { bool dd = 0; string res = ""; for (int i = st1, j = st2; i < st2 && j <= n; i++, j++) { if (s[i] == s[j]) res.PB(s[i]); else { if (dd) break; if (id == 1) i--; else j--; dd = 1; continue; } } if (res.length() != n/2) return "NOT"; return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); //freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); cin >> n >> s; if (n & 1 == 0) return cout << "NOT POSSIBLE", 0; s = "#" + s; //cout << s << '\n'; ans[1] = Check(1, n/2+1, 1); ans[2] = Check(1, n/2+2, 2); //cout << ans[1] << ' ' << ans[2] << '\n'; if (ans[1] == "NOT" && ans[2] == "NOT") return cout << "NOT POSSIBLE", 0; if (ans[1] == "NOT") return cout << ans[2], 0; if (ans[2] == "NOT") return cout << ans[1], 0; if (ans[1] == ans[2]) return cout << ans[1], 0; cout << "NOT UNIQUE"; return 0; }

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

friends.cpp: In function 'std::__cxx11::string Check(int, int, int)':
friends.cpp:48:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (res.length() != n/2) return "NOT";
         ~~~~~~~~~~~~~^~~~~~
friends.cpp: In function 'int main()':
friends.cpp:58:15: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
     if (n & 1 == 0) return cout << "NOT POSSIBLE", 0;
             ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...