2024 ICPC Asia EC网络预选赛第二场

赛后总结

学校ICPC刚立项,因此也是第一次参加ICPC,经验有所不足,首先是比赛前没把笔记本自带的键盘禁用导致不能外接键盘,写代码速率稍微受到影响;另外我开赛前特地把队长用机摆在中间,后来才意识到应该摆在边边上,导致我们讨论题目时很多时候是两个人坐在一条椅子上,之前参加浙江省ACM竞赛也看过现场比赛时机器的摆放,这波纯属是犯病了。主要还是实力不足,考虑的不够全面,导致WA了14发,排名受到极大的影响,不过最后几分钟AC了一题,也算是比较圆满。最后我们因为太多的罚时只能排在6题末,止步网络赛。

榜单​​​​​

公共榜单 - 2024 ICPC Asia EC网络预选赛(第二场) (pintia.cn)

感谢Father_Cai和会长大人带飞,下面是我们的AC代码(按AC的先后顺序排序)

F(c++)

#include <iostream>

using namespace std;

int n;
int m = 1500;
bool flag = false;

int main() {
    cin >> n;
    for (int i = 0; i < n; i ++ ) {
        int a;
        cin >> a;
        m += a;
        if (m >= 4000 && !flag) {
            cout << i + 1;
            flag = true;
        }
    }
    if (!flag )cout << "-1";
}

J(c++)

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;
int n;
struct Item {
    ll v, w, c;
    bool operator<(const Item &  other)const {
        return w * other.c < other.w * c;
    }
} a[N];
ll s[N], res = 0;

void output() {
    for (int i = 0; i  < n; i ++ ) {
        cout << a[i].w << " " << a[i].v << " " << a[i].c << " " << endl;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].w >> a[i].v >> a[i].c;
    }
    sort(a, a + n);
    for (int i = n-1; i>=0; i--) s[i] = s[i+1] +a[i].w;

    // output();
    for (int i = n-1; i >= 0; i--) res += max(a[i].v - s[i+1] * a[i].c, (ll)0);
    cout << res;

}

L(c++)

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;
ll q, n;

ll gcd(ll x, ll y) {return y == 0 ? x : gcd(y, x % y);}

double cal(double x) {
    double res = (double)(2 * n * n - x * n + x * n * x) / (double)(2 * n * x);
    return res;
}

int main() {
    scanf("%d", &q);
    while (q -- ) {
        scanf("%ld", &n);
        double t = sqrt(2.* n);
        double lower = floor(t), upper = ceil(t);
        int x;
        if (cal(lower) <= cal(upper)) x = lower;
        else x = upper;
        ll fm = 2 * x * n, fz = 2 * n * n - n * x + n * x * x;
        ll tmp = gcd(fm, fz);
        fm /= tmp, fz /= tmp;
        cout << fz << " " << fm << "\n";
    }    
} 

 A(c++)

#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
using namespace std;

const int N = 1e5+10, inf = 0x3f3f3f3f;
int n, k, m;

struct Item {
    int index;
    int w;
    string name;
    int res;
} a[N];
unordered_map<string, int> table;

bool cmp1(const Item & a, const Item & b) {
    return a.w > b.w;
}
bool cmp2(const Item & a, const Item & b) {
    return a.index < b.index;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;
    m = inf;
    for (int i = 0; i < k; i++) {
        int t;
        cin >> t;
        m = min(t, m);
    }
    for (int i = 0; i < n; i++) {
        a[i].index = i;
        cin >> a[i].w >> a[i].name;
        table[a[i].name] = 0;
    }

    sort(a, a+n, cmp1);

    int res = 0;
    for (int i = 0; i < n; i++) {
        if (table[a[i].name] == m) a[i].res = res;
        else a[i].res = res+1;
        if (table[a[i].name] == m)  continue;
        table[a[i].name]++;
        res++;
    }
    
    sort(a, a+n, cmp2);

    for (int i = 0; i < n; i++) cout << a[i].res << "\n";

}

I(python3)

t = int(input())
for i in range(t):
    n = int(input())
    if n % 4 == 0:
        print("NO")
        continue
    print("YES")
    n_bin = bin(n)[2:]
    n_bin_len = len(n_bin)
    res = [1]+[-1]*(32-n_bin_len)+list(n_bin[1:])
    cnt = 0
    for i,x in enumerate(res):
        if x == '0':
            cnt += 1
            if cnt == 2:
                res[i-1]=1
                res[i] = -1
            elif cnt > 2:
                res[i] = -1
        else:
            if cnt > 1:
                res[i] = -1
            cnt = 0
            
    res.reverse()
    ans = 0
    for i in range(len(res)):
        ans += int(res[i]) * 2 **i
    print(ans)
    print(*res[:8])
    print(*res[8:16])
    print(*res[16:24])
    print(*res[24:])
        

G(c++)

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

// typedef long long int64_t;
const int64_t mod = 998244353;
int q;
int64_t a = 1;

int64_t qmi(int64_t a, int64_t k, int64_t p) {
    int64_t res = 1;
    while (k) {
        if (k & 1) res = res * a %p;
        a = a * a % p;
        k >>= 1;
    }
    return res;
}

void slove() {
    int64_t res = 0, now = 1;
    int64_t x, y;
    cin >> x >> y;
    int64_t p0, p1, _;
    cin >> p0 >> p1 >> _;
    if (p1 == 0) {
        cout << "1" << endl;
        return;
    }
    int64_t all = p0 + p1;
    
    while (true) {
        if (x < y) {
            int64_t cnt = ceil((double)(y - x) / x);
            int64_t youhua_p0 = qmi(p0, cnt, mod);
            int64_t youhua_all = qmi(all, cnt, mod);
            y -= x * cnt;
            now = ((now * youhua_p0) % mod * qmi(youhua_all, mod - 2, mod)) % mod;
        } else if (x == y) {
            // now * p0 / all
            now = ((now * p0) % mod * qmi(all, mod - 2, mod)) % mod;
            // res += now
            res = (res + now) % mod;
            break;
        } else {
            // n
            int64_t cnt = ceil((double)(x - y) / y);
            // p1 ^ n
            int64_t youhua_p1 = qmi(p1, cnt, mod);
            // all ^ n
            int64_t youhua_all = qmi(all, cnt, mod);


            int64_t left_up = (p0 * qmi(all, cnt, mod)) % mod;
            int64_t right_up = (p0 * qmi(p1, cnt, mod)) % mod;
            int64_t up = ((mod + left_up - right_up) % mod) * now % mod;

            int64_t left_down = qmi(all, cnt + 1, mod);
            int64_t right_down = p1 * qmi(all, cnt, mod) % mod;
            int64_t down = (left_down - right_down + mod) % mod;
            res = (res + (up * qmi(down, mod - 2, mod)) % mod) % mod;


            now = ((now * youhua_p1) % mod * qmi(youhua_all, mod - 2, mod)) % mod;
            x -= y * cnt;
        }
    }
    cout << res << endl;
}

int main() {
    cin >> q;
    while (q -- ) {
        slove();
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值