백준

    [실5] 4659 - 비밀번호 발음하기

    #include #include #include using namespace std; bool IsVocal(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; } int maxCnt = 3; int main() { vector res; string s = ""; while (true) { string tmp = ""; bool hasVocal = false, flag = false, fail = false;; cin >> s; if(s == "end") break; for (int i = 0; i < s.size() + 1; i++) { char cur = i < s.size() ? s[i] : ' '; // 1. 모음(..

    [실4] 1755 - 숫자놀이

    #include #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); const string numbers[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", }; vector ans; int n, m; cin >> n >> m; for (size_t i = n; i = 10) s = numbers[i / 10] + " " + numbers[i % 10]; else s = numbers[i % 10]; ans.push_back({ s,i ..

    [실5] 14916 - 거스름돈

    #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, res = 0; cin >> n; if (n < 5) res = (n % 2 == 0) ? n / 2 : -1; else { int q = n / 5; if (n % 5 == 0) res = q; else { int remain = n - q * 5; if (remain % 2 == 0) res = q + remain / 2; else res = (q - 1) + (remain + 5) / 2; } } cout

    [실4] 28278 - 스택 2

    #include #include #include using namespace std; stack s; string res; void Push(int n) { s.push(n); } void Pop() { if (s.empty()) res += to_string(-1) + '\n'; else { res += to_string(s.top()) + '\n'; s.pop(); } } void Size() { res += to_string(s.size()) + '\n'; } void Empty() { res += to_string(s.empty()) + '\n'; } void Top() { res += to_string(s.empty() ? -1 : s.top()) + '\n'; } int main() { ios..

    [실5] 2563 - 색종이

    #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int arr[100][100]{ 0 }; int n; cin >> n; for (size_t i = 0; i > n1 >> n2; for (size_t j = n1; j < n1 + 10; j++) { for (size_t k = n2; k < n2 + 10; k++) arr[j][k] = 1; } } int sum = 0; for (size_t i = 0; i < 100; i++) { for (size_t j = 0; j < 1..

    [실4] 10845 - 큐

    #include #include #include using namespace std; queue q; string res; void Push(int x) { q.push(x); } void Pop() { if (q.empty()) res += to_string(-1) + '\n'; else { res += to_string(q.front()) + '\n'; q.pop(); } } void Size() { res += to_string(q.size()) + '\n'; } void Empty() { res += to_string(q.empty() ? 1 : 0) + '\n'; } void Front() { res += to_string(q.empty() ? -1 : q.front()) + '\n'; } vo..

    [실4] 10816 - 숫자 카드 2

    #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; map data; for (int i = 0; i > val; data[val]++; } string s; int m; cin >> m; for (int i = 0; i > val; s += to_string(data[val]); if (i < m - 1) s += ' '; } cout

    [실4] 2003 - 수들의 합2

    #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, s = 0, e = 0; cin >> n >> m; int* arr = new int[n]; for (int i = 0; i > arr[i]; int sum = 0, res = 0; while (e m) sum -= arr[s++]; else { res++; sum += arr[e++]; } } cout

    [골4] 1197 - 최소 스패닝 트리

    #include #include #include using namespace std; class Edge { public: int node[2]; int dist; Edge(int a, int b, int dist) { node[0] = a; node[1] = b; this->dist = dist; } bool operator> vertex >> edge; for (int i = 0; i > from >> to >> cost; v.push_back(Edge(from, to, cost)); } sort(v.begin(), v.end..

    [골4] 14502 - 연구소

    참고해서 코드 작성 #include #include #include #include #define y first #define x second using namespace std; using IntPair = pair; using TwoDVec = vector; IntPair dir[] { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } }; TwoDVec m, vm; vector vis; int h, w, ans = 0; // 바이러스 지도 초기화 함수 void SetMap() { for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) vm[i][j] = m[i][j]; } } void SpreadVirus() { queue q;..