1-G질문있습니다
미해결
10주완성 C++ 코딩테스트 | 알고리즘 코딩테스트
강의 재밌게 듣고 있습니다 그런데 1-G에서 반례(크기까지 고려)고려해야 한다고 하신 부분까지 반영되었다고 생각하는데 맞왜틀이 됩니다... 혹시 어디서 틀려서 그런지 알려주시면 정말 감사하겠습니다. #include <bits/stdc++.h> using namespace std; int main() { int tc; string pattern; cin>>tc; cin>>pattern; string front=""; string back=""; bool chk = false; for(auto c: pattern){ if(c=='*') {chk=true;continue;} if(!chk) front+=c; else back+=c; } while(tc--){ string test; cin>>test; int pos1=0,tmp1; vector<int> v1; while((tmp1=(int)test.find(front,pos1))!=-1) { v1.push_back(tmp1); pos1=tmp1+1; } int pos2=0,tmp2; vector<int> v2; while((tmp2=(int)test.find(back,pos2))!=-1) { v2.push_back(tmp2); pos2=tmp2+1; } bool fin = false; for(auto i : v1){ for(auto j : v2){ if(i+front.size()<=j) {cout<<"DA"<<'\n';fin=true;break;} } if(fin) break; } if(!fin) cout<<"NE"<<'\n'; } }
- 1-G
- C++
- 코테 준비 같이 해요!





