注意: \color{red}{注意:} 注意: 个人博客传送门
A. 时间
思路:
- 基础语法
时间复杂度: O ( 1 ) O(1) O(1)
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::cout << (n % 12 ? n % 12 : 12) << "\n";
return 0;
}
B. 数对推理
思路:
- 讲真的题目感觉都没说清楚,读起来莫名其妙的
时间复杂度: O ( ) O() O()
C. 铺瓷砖
思路:
- 设向量搜索即可,可以发现在竖着的方向上一直都有两个方块,所以我们可以设向量来搜索即可
时间复杂度: O ( n ) O(n) O(n)
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::vector<std::string> g(2);
for (int i = 0; i < 2; i++) {
std::cin >> g[i];
g[i] = '1' + g[i] + '1';
}
int n = g[0].size() - 2;
int ans = 0;
std::array<int, 4> dy {-1, -1, 1, 1}, dx {1, 0, 1, 0};
for (int i = 1; i <= n; i++) {
if (g[1][i] == '0' && g[0][i] == '0') {
for (int j = 0; j < 4; j++) {
int x = dx[j], y = dy[j] + i;
if (g[x][y] == '0') {
g[x][y] = g[0][i] = g[1][i] = '1';
ans++;
break;
}
}
}
}
std::cout << ans << "\n";
return 0;
}