Codeforces Round #682 (Div. 2)

Codeforces Round #682 (Div. 2)

A. Specific Tastes of Andre

#include <bits/stdc++.h>

#define int ll
using namespace std;
typedef long long ll;
const int maxn = 3e4 + 10;
const int mod = 998244353;

void solve() {
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cout<<"1 ";
    }
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
       solve();
    }
    return 0;
}

B. Valerii Against Everyone

因为ai=2^bi,所以如果有两段相等必有俩个相等的数。

#include <bits/stdc++.h>

#define int ll
using namespace std;
typedef long long ll;
const int maxn = 3e4 + 10;
const int mod = 998244353;

map<int ,int >mp;

void solve() {
    mp.clear();
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin>>x;
        mp[x]++;
    }
    for(auto x:mp)
        if(x.second>1) {
            cout<<"YES\n";
            return;
        }
    cout<<"NO\n";
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
       solve();
    }
    return 0;
}

C. Engineer Artem

奇偶错位,这没想到铁锅铁锅。

#include <bits/stdc++.h>

#define int ll
using namespace std;
typedef long long ll;
const int maxn = 3e4 + 10;
const int mod = 998244353;

void solve() {
    int n,m,x;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>x;
            cout<<((i+j)%2!=x%2)+x<<" ";
        }
        cout<<"\n";
    }
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
       solve();
    }
    return 0;
}

D. Powerful Ksenia

#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int maxn=1e5+5;

int solve() {
    int n,sum=0,a;
    cin>>n;
    for (int i = 1; i <=n; ++i) cin>>a,sum^=a;
    if(n%2==0) {
        if(sum) return cout<<"NO\n",0;
        n--;
    }
    cout<<"YES\n"<<n-1<<"\n";
    for (int i = 1; i < n; i+=2)
        cout<<i<<" "<<i+1<<" "<<i+2<<"\n";
    for (int i = 1; i < n; i+=2)
        cout<<i<<" "<<i+1<<" "<<n<<"\n";
    /*for (int i = 1; i < n; i+=2) {
        int x=a[i+1]^a[0]^a[i];
        a[0]=x;
        a[i]=x;
        a[i+1]=x;
    }
    for (int i = 1; i < n; i+=2) {
        int x=a[i+1]^a[0]^a[i];
        a[0]=x;
        a[i]=x;
        a[i+1]=x;
    }
    for (int i = 0; i < n; ++i) {
        cout<<a[i]<<" ";
    }*/
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--) {
       solve();
    }
    return 0;
}

E. Yurii Can Do Everything

#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int maxn=2e5+5;

int a[maxn];
int sum[maxn];
set<pair<int ,int >> se;

int solve() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=1;i<=n;i++){
        for (int j = i+1; j <=n; ++j) {
            if((a[j+1]^a[i])==sum[j]-sum[i])
                se.insert({i,j+1});
            if(sum[j]-sum[i]>max(a[i],a[j+1])*2) break;
        }
        for (int j = i-1; j >1; --j) {
            if((a[j-1]^a[i])==sum[i-1]-sum[j-1])
                se.insert({j-1,i});
            if(sum[i-1]-sum[j-1]>max(a[i],a[j-1])*2) break;
        }
    }
    cout<<se.size();
}

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--) {
       solve();
    }
    return 0;
}

F. Olha and Igor

#include<bits/stdc++.h>

#define rep(i, x, n)  for(int i = x ; i <= n ; i ++)
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 10;
int h, n;

struct node {
    int val, id;
    bool operator<(const node &s) const {
        return val > s.val;
    }
} cnt[maxn];

void ask() {
    int u, v, w;
    u = rand() % n + 1;
    v = rand() % n + 1;
    w = rand() % n + 1;
    while (v == u || v == w || w == u) {
        v = rand() % n + 1;
        w = rand() % n + 1;
    }
    printf("? %d %d %d\n", u, v, w);
    fflush(stdout);
    int x;
    scanf("%d", &x);
    cnt[x].val++;
}

int main() {
    srand(time(0));
    scanf("%d", &h);
    n = (1 << h) - 1;
    rep(i, 1, n) cnt[i].id = i, cnt[i].val = 0;
    rep(i, 1, 420) ask();
    sort(cnt + 1, cnt + n + 1);
    int ans = 1;
    rep(i, 1, n) {
        if (i == cnt[1].id || i == cnt[2].id) continue;
        printf("? %d %d %d\n", cnt[1].id, cnt[2].id, i);
        fflush(stdout);
        int x;
        scanf("%d", &x);
        if (x == i) ans = x;
    }
    printf("! %d\n", ans);
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值