AtCoder Beginner Contest 391

https://atcoder.jp/contests/abc391

Signed-off-by: Frederick Chen <seventeen@ohdragonboi.cn>
This commit is contained in:
Frederick Chen 2025-04-19 10:09:51 +08:00
parent ee1f0db08b
commit ebb7f9ba04
3 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#include <bits/stdc++.h>
#define lo long long
#define INF INT_MAX
#define LLM LONG_LONG_MAX
using namespace std;
const int N = 1e7 + 10;
/*
toothless. #17
@fredcss_dev
*/
map<string, string> mp;
string n;
signed main()
{
mp["N"] = "S";
mp["E"] = "W";
mp["W"] = "E";
mp["S"] = "N";
mp["NE"] = "SW";
mp["NW"] = "SE";
mp["SE"] = "NW";
mp["SW"] = "NE";
cin >> n;
cout << mp[n];
return 0;
}

View File

@ -0,0 +1,48 @@
#include <bits/stdc++.h>
#define lo long long
#define INF INT_MAX
#define LLM LONG_LONG_MAX
using namespace std;
const int N = 1e7 + 10;
/*
toothless. #17
@fredcss_dev
*/
signed main() {
int N, M;
cin >> N >> M;
vector<vector<char> > S(N, vector<char>(N));
vector<vector<char> > T(M, vector<char>(M));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) {
cin >> S[i][j];
}
}
for (int i = 0; i < M; ++i) {
for (int j = 0; j < M; ++j) {
cin >> T[i][j];
}
}
for (int a = 0; a <= N - M; ++a) {
for (int b = 0; b <= N - M; ++b) {
bool match = true;
for (int i = 0; i < M; ++i) {
for (int j = 0; j < M; ++j) {
if (S[a + i][b + j] != T[i][j]) {
match = false;
break;
}
}
if (!match) break;
}
if (match) {
cout << a + 1 << " " << b + 1 << endl;
}
}
}
return 0;
}

View File

@ -0,0 +1,32 @@
#include <iostream>
#include <vector>
using namespace std;
int n, q, mp[10005], g[10005], cnt = 0, a, b, c;
int main()
{
cin >> n >> q;
for (int i = 0; i <= n; i++)
{
mp[i] = 1;
g[i] = i;
}
while (q--)
{
cin >> a;
if (a == 1)
{
cin >> b >> c;
if (mp[g[b]] == 2)
cnt--;
if (mp[c] == 1)
cnt++;
mp[g[b]]--;
mp[c]++;
g[b] = c;
}
else if (a == 2)
cout << cnt << endl;
return 0;
}