๋ฌธ์
ํ์ด
์ผํ๋ค๊ฐ ์ ๊ท์์ ๋ง์ด ๊ฒฝํํ๋๋ฐ ๋ฑ ๋ณด์๋ง์ ๊ทธ๋ฅ ์ ๊ท์ ์ฐ๋ผ๋ ๋ฌธ์ ๋ผ๊ณ ์๊ฐํ๋ค.
(100+1+|01)+๊ฐ ๋์ด๋ค..
์ ๊ท์ ๋ช๋ฐฑ์์ง๋ฆฌ ์กฐ๊ฑด๋ง์ถ๋๋ผ ๋๋ฌผํ๋ฆฌ๋ฉด์ ์ผ์๋๋ฐ ๋์์ด ๋๋๊ฑฐ๊ฐ๋ค.
#include <iostream>
#include <regex>
#include <string>
using namespace std;
bool matchReg(const string& str) {
regex reg("(100+1+|01)+");
return regex_match(str, reg);
}
int main() {
string str;
cin>>str;
if(matchReg(str)) cout<<"SUBMARINE"<<endl;
else cout<<"NOISE"<<endl;
}
'algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
DP - ์์ดํ ์ ์ ์ ํ ๊ณ ๋ฅด๋ ๋ฌธ์ (0) | 2025.03.21 |
---|---|
935 div2 C. Manhattan Permutations (0) | 2024.08.07 |
๋ฐฑ์ค 14848 (0) | 2024.08.02 |
๋ฐฑ์ค 1953 (0) | 2024.08.01 |
๋ฐฑ์ค 25690 (0) | 2024.07.31 |