제출 #554524

#제출 시각아이디문제언어결과실행 시간메모리
554524Awerar세 명의 친구들 (BOI14_friends)C++14
100 / 100
70 ms8496 KiB
#include <iostream> #include <vector> #include <string> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <limits.h> #include <math.h> #include <chrono> #include <queue> #include <stack> #include <algorithm> using namespace std; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define ll long long #define vi vector<ll> #define vvi vector<vi> #define p2 pair<ll, ll> #define p3 tuple<ll,ll,ll> #define p4 vi #define ip3 tuple<int,int,int> #define ip4 tuple<int,int,int,int> #define vp2 vector<p2> #define vp3 vector<p3> #define inf 2e9 #define linf 1e17 #define read(a) cin >> a #define write(a) cout << (a) << "\n" #define dread(type, a) type a; cin >> a #define dread2(type, a, b) dread(type, a); dread(type, b) #define dread3(type, a, b, c) dread2(type, a, b); dread(type, c) #define dread4(type, a, b, c, d) dread3(type, a, b, c); dread(type, d) #define dread5(type, a, b, c, d, e) dread4(type, a, b, c, d); dread(type, e) #ifdef _DEBUG #define deb __debugbreak(); #else #define deb ; #endif #define rep(i, high) for (ll i = 0; i < high; i++) #define repp(i, low, high) for (ll i = low; i < high; i++) #define repe(i, container) for (auto& i : container) #define per(i, high) for (ll i = high; i >= 0; i--) #define readpush(type,vect) type temp; read(temp); vect.push_back(temp); #define readvector(type, name, size) vector<type> name(size); rep(i,size) {dread(type,temp); name[i]=temp;} #define readinsert(type,a) {type temp; read(temp); a.insert(temp);} #define all(a) begin(a),end(a) #define setcontains(set, x) (set.find(x) != set.end()) #define stringcontains(str, x) (str.find(x) != string::npos) #define within(a, b, c, d) (a >= 0 && a < b && c >= 0 && c < d) #define ceildiv(x,y) ((x + y - 1) / y) #define fract(a) (a-floor(a)) #define sign(a) ((a>0) ? 1 : -1) auto Start = chrono::high_resolution_clock::now(); inline void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } #define NP "NOT POSSIBLE" #define NU "NOT UNIQUE" int main() { //fast(); dread(int, n); dread(string, u); if(n % 2 == 0) { write(NP); return 0; } ll s_len = (u.size() - 1) / 2; //Assume wrong is in second string s1 = ""; for(int i = 0; i < s_len; i++) { s1 += u[i]; } bool found_wrong1 = false; bool valid1 = true; for(int i = 0; i < s_len; i++) { int k = i + s_len; if(found_wrong1) k++; if(s1[i] != u[k]) { if(found_wrong1 || u[k + 1] != s1[i]) { valid1 = false; break; } found_wrong1 = true; } } //if(!found_wrong1) valid1 = false; //Assume wrong is in first string s2 = ""; for(int i = 0; i < s_len; i++) { s2 += u[i + s_len + 1]; } bool found_wrong2 = false; bool valid2 = true; for(int i = 0; i < s_len; i++) { int k = i; if(found_wrong2) k++; if(s2[i] != u[k]) { if(found_wrong2 || u[k + 1] != s2[i]) { valid2 = false; break; } found_wrong2 = true; } } if(valid1 && valid2) { if(s1 == s2) write(s1); else write(NU); } else if(valid1) { write(s1); } else if (valid2) { write(s2); } else { write(NP); } } /* 7 ABXCABC 6 ABCDEF 9 ABABABABA 7 ABXCABD */

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

friends.cpp:18: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   18 | #pragma GCC optimization ("O3")
      | 
friends.cpp:19: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   19 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...