AtCoder Beginer Contest 236 ABCD签到

AtCoder Beginer Contest 236 ABCD签到,第1张

AtCoder Beginer Contest 236 ABCD签到 A.chukodai

拼手速

#include 
using namespace std;

inline void solve(){
    string s; cin >> s;
    int a, b; cin >> a >> b;
    for(int i = 0; i < s.size(); i++){
        if(i == a - 1) cout << s[b - 1];
        else if(i == b - 1) cout << s[a - 1];
        else cout << s[i];
    }
}

signed main(){
    solve();
    return 0;
}
B.Who is missing?

拼手速

#include 
using namespace std;

const int N = 1e6 + 10;
int a[N];

inline void solve(){
    int n = 0; cin >> n;
    for(int i = 1; i <= 4 * n - 1; i++){
        int num = 0; cin >> num;
        a[num]++;
    }
    for(int i = 1; i <= n; i++)
        if(a[i] < 4){ cout << i << endl; return; }
}

signed main(){
    solve();
    return 0;
}
C.Route Map

拼手速

#include 
using namespace std;

const int N = 1e5 + 10;
string s[N];
map t;

inline void solve(){
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> s[i];
    for(int i = 1; i <= m; i++){
        string ss; cin >> ss;
        t[ss] = 1;
    }
    for(int i = 1; i <= n; i++){
        if(t.count(s[i])) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

signed main(){
    solve();
    return 0;
}
D.Dance

暴力枚举即可, 1 ≤ N ≤ 8 1leq N leq 8 1≤N≤8。

#include 
#define int long long 
using namespace std;

const int N = 100;
int a[N][N], vis[1000], n, cnt, ans, tmp = 0;

void dfs(int now){
    if(now == (n << 1 | 1)){ if (cnt == (n << 1) && tmp > ans) ans = tmp; return; }
    if(vis[now]){ dfs(now + 1); return; }
    for(int i = now + 1; i <= 2 * n; i++){
        if(vis[i] == 1) continue;
        vis[i] = vis[now] = 1, tmp ^= a[now][i], cnt += 2;
        dfs(now + 1);
        vis[i] = vis[now] = 0, tmp ^= a[now][i], cnt -= 2;
    }
}

inline void solve(){
    cin >> n;
    for(int i = 1; i <= 2 * n - 1; i++)
        for(int j = i + 1; j <= 2 * n; j++) cin >> a[i][j];
    dfs(1);
    cout << ans << endl;
}

signed main(){
    solve();
    return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5711683.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存