mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Upload codes: contests
This commit is contained in:
34
AtCoder/abc390/A_12435.cpp
Normal file
34
AtCoder/abc390/A_12435.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#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
|
||||
*/
|
||||
|
||||
int a[N], b[N];
|
||||
|
||||
signed main()
|
||||
{
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
cin >> a[i];
|
||||
b[i] = a[i];
|
||||
}
|
||||
if (a[1] == 1 && a[2] == 2 && a[3] == 3 && a[4] == 4 && a[5] == 5) {
|
||||
puts("No");
|
||||
return 0;
|
||||
}
|
||||
sort(b + 1, b + 6);
|
||||
int cnt = 0, r = 0;
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
if (a[i] != b[i]) cnt++;
|
||||
if (a[i] != b[i] && i != 1 && a[i - 1] != b[i - 1]) r = 1;
|
||||
}
|
||||
if (cnt == 2 && r == 1) puts("Yes");
|
||||
else puts("No");
|
||||
return 0;
|
||||
}
|
33
AtCoder/abc390/B_Geometric_Sequence.cpp
Normal file
33
AtCoder/abc390/B_Geometric_Sequence.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define lo long long
|
||||
#define INF INT_MAX
|
||||
#define LLM LONG_LONG_MAX
|
||||
|
||||
using namespace std;
|
||||
const lo N = 1e7 + 10;
|
||||
/*
|
||||
toothless. #17
|
||||
@fredcss_dev
|
||||
*/
|
||||
|
||||
lo n;
|
||||
lo a[N], b;
|
||||
bool flag = 0;
|
||||
|
||||
signed main()
|
||||
{
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
for (int i = 3; i <= n; i++)
|
||||
{
|
||||
if (a[i] * a[1] != a[i - 1] * a[2])
|
||||
{
|
||||
puts("No");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
puts("Yes");
|
||||
return 0;
|
||||
}
|
60
AtCoder/abc390/C_Paint_to_make_a_rectangle.cpp
Normal file
60
AtCoder/abc390/C_Paint_to_make_a_rectangle.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#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
|
||||
*/
|
||||
|
||||
bool f(int h, int w, vector<string>& g)
|
||||
{
|
||||
int top = h, b = -1, l = w, r = -1;
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
if (g[i][j] == '#') {
|
||||
top = min(top, i);
|
||||
b = max(b, i);
|
||||
l = min(l, j);
|
||||
r = max(r, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (b == -1) return true;
|
||||
for (int i = top; i <= b; i++) {
|
||||
for (int j = l; j <= r; j++) {
|
||||
if (g[i][j] == '.') return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
if (i < top || i > b || j < l || j > r) {
|
||||
if (g[i][j] == '#') return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
int h, w;
|
||||
cin >> h >> w;
|
||||
if (h == 1 && w == 1) {
|
||||
puts("Yes");
|
||||
return 0;
|
||||
}
|
||||
vector<string> g(h);
|
||||
for (int i = 0; i < h; i++) {
|
||||
cin >> g[i];
|
||||
}
|
||||
if (f(h, w, g)) {
|
||||
cout << "Yes" << endl;
|
||||
} else {
|
||||
cout << "No" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
30
AtCoder/abc391/A_Lucky_Direction.cpp
Normal file
30
AtCoder/abc391/A_Lucky_Direction.cpp
Normal 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;
|
||||
}
|
48
AtCoder/abc391/B_Seek_Grid.cpp
Normal file
48
AtCoder/abc391/B_Seek_Grid.cpp
Normal 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;
|
||||
}
|
32
AtCoder/abc391/C_Pigeonhole_Query.cpp
Normal file
32
AtCoder/abc391/C_Pigeonhole_Query.cpp
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user