From f49b42035572ea064c8994c12dd2a50887c4476c Mon Sep 17 00:00:00 2001 From: dhlee777 Date: Mon, 6 May 2024 01:23:11 +0900 Subject: [PATCH] 2024-05-06 AC --- .../AC.cpp" | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 "dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" diff --git "a/dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" "b/dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" new file mode 100644 index 0000000..55ed379 --- /dev/null +++ "b/dhlee777/\353\254\270\354\236\220\354\227\264\354\262\230\353\246\254/AC.cpp" @@ -0,0 +1,86 @@ +#include +#include +#include +#include +using namespace std; +vectorv; //¹è¿­ÀÇ ¿ø¼ÒµéÀ» ÀúÀåÇÒ º¤ÅÍ +string a,b,nm; //a-¸í·É¾îµéÀ» ÀúÀåÇÒ string, b-¹è¿­À» ÀúÀåÇÒ string +int main(void) { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int t,num,start_idx,end_idx; //t-Å×½ºÆ®ÄÉÀ̽º°³¼ö,num-¿ø¼ÒÀÇ°³¼ö,start_idx-½ÃÀÛ À妽º,end_idx-³¡À妽º + int r_cnt = 0; + cin >> t; + while (t--) { + cin >> a>>num>>b; + start_idx = 0; end_idx = num - 1; + r_cnt = 0; + for (int i = 0; i end_idx) + start_idx--; + else if (end_idx > start_idx) + start_idx++; + else end_idx = -1; //½ÃÀÛÀ妽º¿Í ³¡À妽º°¡ °°À»°æ¿ì¿¡ ¿ø¼Ò´Â ÇϳªÁ¸ÀçÇϹǷΠd¸¦ ½ÇÇàÇÒ°æ¿ì º¤ÅÍ°¡ ºñ°ÔµÈ´Ù. + r_cnt = 0; + } + } + if (r_cnt != 0 && end_idx > -1&&r_cnt%2==1) { //Á¦Àϳ¡¿¡ rÀÌ ¿Ã°æ¿ì ºó º¤ÅÍ°¡ ¾Æ´Ï°í rÀÇ°³¼ö°¡ Ȧ¼öÀ϶§ + int temp = start_idx; + start_idx = end_idx; + end_idx = temp; + } + + if (end_idx == -2) cout << "error"<<"\n"; + else if (end_idx == -1) cout << "[]"<<"\n"; + else { + cout << "["; + if (start_idx >= end_idx) { + for (int i =start_idx; i>end_idx; i--) { + cout << v[i] << ","; + } + cout << v[end_idx]<<"]"<<"\n"; + } + else { + for (int i = start_idx; i < end_idx; i++) { + cout << v[i] << ","; + } + cout << v[end_idx]<<"]"<<"\n"; + } + + } + + vector().swap(v); //´Ù¸¥ Å×½ºÆ®ÄÉÀ̽º¸¦ À§ÇÑ º¤ÅÍ ÃʱâÈ­ + + } + + +} \ No newline at end of file