跳到正文

个人记录

8.23-河西校区

Leo_Luo_Xiaohei约 8 分钟
原文
文章信息与版本

文章信息

发布
2025年8月25日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 8 分钟

版本

  1. v1当前

8.23-河西校区

T1

T640710 高铁线路

赛时代码&得分
Accepted1̸00tps\color{green}{Accepted\not100tps}
C++
#include <bits/stdc++.h>
using namespace std;
int n, x, y, z;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> x >> y >> z;
	if (x > y) {
		if (z > x || z < y) 
			cout << "No";
		else if (z <= x && z >= y) 
			cout << "Yes";
	} else if (x < y) {
		if (z < x || z > y) 
			cout << "No";
		else if (z >= x && z <= y) 
			cout << "Yes";
	} else {
		if (z != x) 
			cout << "No";
		else 
			cout << "Yes";
	}
	return 0;
}
T2

U591726 盲打练习

赛时代码&得分
Accepted1̸00tps\color{green}{Accepted\not100tps}
C++
#include <bits/stdc++.h>
using namespace std;
string s, t;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s >> t;
	int lens = s.size(), lent = t.size();
	for (int i = 0, j = 0; i < lens && j < lent; ) {
		if (s[i] == t[j]) {
			i ++;
			j ++;
			cout << j << " ";
		} else if (s[i] != t[j]) 
			j ++;
	}
	return 0;
}
T3

T639117 Int128 游乐园

赛时代码&得分
Accepted1̸00tps\color{green}{Accepted\not100tps}
C++
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, k, x, cur, ans;
queue<int> q;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i ++) {
		cin >> x;
		q.push(x);
	}
	cur = k;
	while (!q.empty()) {
		x = q.front();
		if (x <= cur) {
			cur -= x;
			q.pop();
		} else {
			ans ++;
			cur = k;
		}
//		cout << "x: " << x << " cur:" << cur << " q.size(): " << q.size() << " ans: " << ans << "\n";
	}
	if (cur != k) 
		ans ++;
	cout << ans;
	return 0;
}
T4

T639126 落落的去的数学问题2

赛时得分
Unaccepted1̸0tps\color{red}{Unaccepted\not10tps}
正解
C++
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int N = 3e5 + 5, mod = 1e8;
int n, cnt, sum;
int a[N];
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i ++) 
		cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; i ++) {
        sum += a[i];
        int pos = lower_bound(a + i + 1, a + 1 + n, mod - a[i]) - a;
        cnt += n - pos + 1;
    }
    cout << sum * (n - 1) - cnt * mod;
	return 0;
}
T5

T638485 第K小

赛时得分
Unaccepted1̸0tps\color{red}{Unaccepted\not10tps}
正解
C++
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, k, cnt;
ll a[16];
map<ll, ll> mp;
priority_queue<ll, vector<ll>, greater<ll> >q;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        if (mp[a[i]]) 
            continue;
        q.push(a[i]);
        mp[a[i]] = 1;
    }
    while (q.size()) {
        cnt ++; 
        ll _ = q.top();
        if (cnt == k) {
            cout << q.top();
            return 0;
        }
        q.pop();
        for (int i = 1; i <= n; i ++) {
            if (mp[_ + a[i]]) 
                continue;
            mp[_ + a[i]] = 1;
            q.push(_ + a[i]);
        }
    }
    cout << cnt;
	return 0;
}
T6

U591734 磁铁迷宫

赛时得分
Unaccepted0̸pts\color{red}{Unaccepted\not0pts}
正解
C++
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, k, cnt;
ll a[16];
map<ll, ll> mp;
priority_queue<ll, vector<ll>, greater<ll> >q;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        if (mp[a[i]]) 
            continue;
        q.push(a[i]);
        mp[a[i]] = 1;
    }
    while (q.size()) {
        cnt ++; 
        ll _ = q.top();
        if (cnt == k) {
            cout << q.top();
            return 0;
        }
        q.pop();
        for (int i = 1; i <= n; i ++) {
            if (mp[_ + a[i]]) 
                continue;
            mp[_ + a[i]] = 1;
            q.push(_ + a[i]);
        }
    }
    cout << cnt;
	return 0;
}
原文