5081. 重复局面

摘要
Title: 5081. 重复局面
Tag: 哈希表
Memory Limit: 64 MB
Time Limit: 1000 ms

Powered by:NEFU AB-IN

Link

5081. 重复局面

  • 题意

    判断棋子局面是否重复

  • 思路

    直接将棋子局面放进哈希表中即可

  • 代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    /*
    * @Author: NEFU AB-IN
    * @Date: 2023-08-23 17:28:10
    * @FilePath: \Acwing\5081\5081.cpp
    * @LastEditTime: 2023-08-23 19:15:20
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    #undef int

    #define SZ(X) ((int)(X).size())
    #define ALL(X) (X).begin(), (X).end()
    #define IOS \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr); \
    cout.tie(nullptr)
    #define DEBUG(X) cout << #X << ": " << X << '\n'
    typedef pair<int, int> PII;

    const int N = 1e5 + 10, INF = 0x3f3f3f3f;

    unordered_map <string, int> st;

    signed main()
    {
    // freopen("Tests/input_1.txt","r",stdin);
    IOS;
    int n;
    cin >> n;
    cin.ignore();
    for(int i = 1; i <= n; ++ i){
    string s;
    for(int i = 1; i <= 8; ++ i){
    string ss;
    getline(cin, ss);
    s += ss;
    }
    st[s] += 1;
    cout << st[s] << '\n';
    }
    return 0;
    }

使用搜索:谷歌必应百度