比赛 2024暑假C班集训8 评测结果 AAAAA
题目名称 轮盘游戏 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2024-07-08 11:33:32
显示代码纯文本
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
const int N = 5e5+10;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
    return x * f;
}


int n,m;
int a[N],b[N],s[N];
bool v[N];
char c;
void solve(){
    int now = 0;
    for(int i = m;i >= 1;i--){
        if(s[now] && s[now] != b[i])return printf("!\n"),void();
        if(!s[now] && v[b[i]])return printf("!\n"),void();
        s[now] = b[i];v[b[i]] = 1;
        now = (now + a[i]) % n;
    }
    for(int i = 0;i < n;i++)
        if(!s[i])printf("?");
        else cout<<char(s[i]);
    printf("\n");
}
int main(){
    freopen("wheel.in","r",stdin);
    freopen("wheel.out","w",stdout);
    while(~scanf("%d%d",&n,&m)){
        memset(a,0,sizeof a);
        memset(v,0,sizeof v);
        memset(b,0,sizeof b);
        memset(s,0,sizeof s);
        for(int i = 1;i <= m;i++){
            a[i] = read();cin>>c;
            b[i] = int(c);
        }
        solve();
    }
    
    return 0;
    
}