河南省第十三届ICPC大学生程序设计竞赛(重现赛)

重现赛链接

A:

思路: 

判断四个坐标的值是否相等

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <climits>
#include <unordered_map>
using namespace std;
#define mst(x, y) memset(x, y, sizeof x)
#define X first
#define Y second
#define int long long
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 200010, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const double EPS = 1e-6;
typedef pair<int, int> PII;
typedef unordered_map<int, int> Ump;
int T;
int n, m;
int a[1100][1100];
int h, w;
bool f;
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> a[i][j];
        }
    }
    cin >> h >> w;

    for (int i = 1; i + h - 1 <= n; i++)
    {
        for (int j = 1; j + w - 1 <= m; j++)
        {
            // A[x][y], A[x + H - 1][y], A[x][y + W - 1], A[x + H - 1][y + W - 1]
            if (a[i][j] == a[i + h - 1][j] && a[i][j] == a[i][j + w - 1] && a[i][j] == a[i + h - 1][j + w - 1])
            {
                f = true;
                break;
            }
        }
        if (f)
            break;
    }

    for (int i = 1; i + w - 1 <= n; i++)
    {
        for (int j = 1; j + h - 1 <= m; j++)
        {
            if (a[i][j] == a[i + w - 1][j] && a[i][j] == a[i][j + h - 1] && a[i][j] == a[i + w - 1][j + w - 1])
            {
                f = true;
                break;
            }
        }
        if (f)
            break;
    }

    if (f)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
}
signed main()
{
    FAST;
    // cin >> T;
    T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}

F:

 

思路:

注意数学坐标系与矩阵行列坐标系的转换,数每行每列最多的*作为坐标轴,转换坐标关系后可直接计算

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <climits>
#include <unordered_map>
using namespace std;
#define mst(x, y) memset(x, y, sizeof x)
#define X first
#define Y second
#define int long long
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 200010, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const double EPS = 1e-6;
typedef pair<int, int> PII;
typedef unordered_map<int, int> Ump;
int T;
int n, m;
char g[1100][1100];
int hh[1100], ll[1100];
int l, h;
int x, y;
void solve()
{
    mst(hh, 0), mst(ll, 0);

    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            cin >> g[i][j];
            if (g[i][j] == '#')
            {
                x = i, y = j;
            }
            if (g[i][j] == '*')
            {
                hh[i]++;
                ll[j]++;
            }
        }

    for (int i = 1; i <= n; i++)
    {
        if (hh[i] > hh[h])
        {
            h = i;
        }
    }

    for (int i = 1; i <= m; i++)
    {
        if (ll[i] > ll[l])
        {
            l = i;
        }
    }

    h = m - h + 1;
    swap(l, h);
    x = m - x + 1;
    swap(x, y);
    cout << x - h << " " << y - l << endl;
    // cout << h << ' ' << l << endl;
}
signed main()
{
    FAST;
    //     cin >> T;
    T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}
/*
10 10
*.........
*.........
*.........
*........#
*.........
*.........
*.........
**********
*.........
*.........
*/

M:

 

思路: 

m个区间不重合,那直接区间长度求和即可

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <climits>
#include <unordered_map>
using namespace std;
#define mst(x, y) memset(x, y, sizeof x)
#define X first
#define Y second
#define int long long
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 200010, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const double EPS = 1e-6;
typedef pair<int, int> PII;
typedef unordered_map<int, int> Ump;
int T;
int n, m, k;
int sum;
void solve()
{
    cin >> n >> m >> k;
    for (int i = 1, x, y; i <= m; i++)
    {
        cin >> x >> y;
        sum += y - x;
    }
    for (int i = 1, x; i <= k; i++)
    {
        cin >> x;
    }
    cout << sum << endl;
}
signed main()
{
    FAST;
//     cin >> T;
    T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}

I:

每次操作时先放一个硬币,再移动一次 

思路:

爆搜两个移动方向

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <climits>
#include <unordered_map>
using namespace std;
#define mst(x, y) memset(x, y, sizeof x)
#define X first
#define Y second
#define int long long
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 200010, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const double EPS = 1e-6;
typedef pair<int, int> PII;
typedef unordered_map<int, int> Ump;
int T;
string s;
bool f;
void dfs(int idx)
{
    if (idx == 7)
    {
        f = true;
        return;
    }

    for (int i = 1; i < s.size(); i++)
    {
        if (s[i] == '0')
        {
            if (s[(i + 2) % 8 + 1] == '0')
            {
                s[(i + 2) % 8 + 1] = '1';
                dfs(idx + 1);
                s[(i + 2) % 8 + 1] = '0';
            }
            else if (s[(i + 4) % 8 + 1] == '0')
            {
                s[(i + 4) % 8 + 1] = '1';
                dfs(idx + 1);
                s[(i + 4) % 8 + 1] = '0';
            }
        }
    }
}
void solve()
{
    int idx = 0;
    cin >> s;
    s = " " + s;
    for (int i = 1; i < s.size(); i++)
    {
        if (s[i] == '1')
            idx++;
    }
    dfs(idx);

    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
signed main()
{
    FAST;
    cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}

L:

高数题,听说可以用格林公式和辛普森公式解,然而并不会又听说可以积分

思路:

随机散点,用概率统计计算面积

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <climits>
#include <unordered_map>
using namespace std;
#define mst(x, y) memset(x, y, sizeof x)
#define X first
#define Y second
#define int long long
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 200010, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const double EPS = 1e-6;
typedef pair<int, int> PII;
typedef unordered_map<int, int> Ump;
int T;
int ans = 0;
double a, b, c, d;
void solve()
{
    ans = 0;
    cin >> a >> b >> c >> d;
    for (double x = -8; x <= 8; x += 0.01)
    {
        for (double y = -8; y <= 8; y += 0.01)
        {
            if (x * x / a / a + y * y / b / b <= 1 || x * x / c / c + y * y / d / d <= 1)
            {
                ans++;
            }
        }
    }
    printf("%.1lf\n", ans * 16.0 * 16.0 / 16 / 100 / 16 / 100);
}
signed main()
{
    FAST;
    cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}

E:

 

本题与风车问题几乎一致(IMO中某题):

1、偶数点必无解
2、奇数个点时:所有点按 x 坐标从小到大排序(若 x 坐标相同则按 y 坐标从小到大排序)。选择排在中间的点,同时做向量(-1,1000000000)

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <climits>
#include <unordered_map>
using namespace std;
#define mst(x, y) memset(x, y, sizeof x)
#define X first
#define Y second
#define int long long
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 200010, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const double EPS = 1e-6;
typedef pair<int, int> PII;
typedef unordered_map<int, int> Ump;
int T;
int n;
struct P
{
    int x, y;
} p[N];
bool cmp(P a, P b)
{
    return a.x < b.x;
}
void solve()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i].x >> p[i].y;
    }

    sort(p + 1, p + 1 + n, cmp);

    if (n % 2 == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        cout << p[n / 2 + 1].x << " " << p[n / 2 + 1].y << " "
             << "-1 1000000000" << endl;
    }
}
signed main()
{
    FAST;
    // cin >> T;
    T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值