알고리즘
백준 11504번 돌려 돌려 돌림판! C++
영춘권의달인
2023. 4. 6. 11:32
https://www.acmicpc.net/problem/11504
11504번: 돌려 돌려 돌림판!
먹고또자니 <거기 누구세요> 코너에서는 "돌림판"을 돌려 상품을 얻을 수 있다. 이 돌림판은 큰 원형판이 N등분되어있는 형태이다. N등분 된 각 부분은 0부터 9사이의 숫자가 하나씩 적혀있다.
www.acmicpc.net
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int t;
vector<char> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
v = vector<char>(n);
string X = "";
string Y = "";
for (int i = 0; i < m; i++) {
char c;
cin >> c;
X += c;
}
for (int i = 0; i < m; i++) {
char c;
cin >> c;
Y += c;
}
for (int i = 0; i < n; i++) {
cin >> v[i];
}
int cnt = 0;
for (int i = 0; i < n; i++) {
string str = "";
for (int j = 0; j < m; j++) {
int idx = (i + j) % n;
str += v[idx];
}
if (X <= str && Y >= str) cnt++;
}
cout << cnt << "\n";
}
}