比赛 2024暑假C班集训8 评测结果 AAAAA
题目名称 轮盘游戏 最终得分 100
用户昵称 darkMoon 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2024-07-08 11:20:58
显示代码纯文本
#include<bits/stdc++.h> 
using namespace std;
//#define fin cin
//#define fout cout
ifstream fin("wheel.in");
ofstream fout("wheel.out");
auto mread = [](){
    int x;
    fin >> x;
    return x;
};
const int N = 105;
int n, m, vis[30];
signed main(){
    while(fin >> n){
        fin >> m;
        int a[m + 5];
        char c[m + 5];
        for(int i = 0; i < 30; i ++)
        vis[i] = 0;
        for(int i = 1; i <= m; i ++){
            a[i] = mread();
            fin >> c[i];
        }
        char s[n + 5];
        for(int i = 0; i < n; i ++)
        s[i] = '?';
        int e = 1, now = 0;
        for(int i = m; i >= 1; i --){
            if(s[now] == '?'){
                if(vis[c[i] - 'A'] == 1){
                    e = 0;
                }
                s[now] = c[i];
                vis[c[i] - 'A'] = 1;
            }
            else if(s[now] == c[i]);
            else{
                e = 0;
            }
            now = (now + a[i]) % n;
        }
        if(e == 0)
        fout << "!\n";
        else{
            for(int i = 0; i < n; i ++)
            fout << s[i];
            fout << "\n";
        }
    }
    return 0;
}