跳到正文

个人记录

8.22-河西校区

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

文章信息

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

版本

  1. v1当前

8.22-河西校区

T1

T639114 大楼

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

T639104 信奥大联赛

赛时代码&得分
Accepted1̸00tps\color{green}{Accepted\not100tps}
C++
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef long long ll;
const int N = 105;
int n, x, sum;
string s[N];
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> s[i] >> x;
		sum += x;
	}
	sort(s, s + n);
	cout << s[sum % n];
	return 0;
}
T3

T638475 调酒大师

赛时代码&得分
C++
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int t, n, m;
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> t;
	while (t --) {
		cin >> n >> m;
		ll res = (ll) n + m >> 2;
		if (m < res) 
			cout << m << "\n";
		else if (n < res) 
			cout << n << "\n";
		else 
			cout << res << "\n";
	}
	return 0;
}
T4

T637889 箭头路径

赛时得分
Unaccepted1̸0tps\color{red}{Unaccepted\not10tps}
正解
C++
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
int t, n;
char a[5][N];
int vis[5][N];
bool b;
void dfs(int x, int y) {
    if (x == 2 && y == n) {
        b = 1;
        return;
    }
	for (int i = 0; i < 4; i ++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx < 1 || nx > 2 || ny < 1 || ny > n || vis[nx][ny]) 
            continue;
        vis[nx][ny] = 1;
        if (a[nx][ny] == '<') 
            ny --;
        else 
            ny ++;
        if (!vis[nx][ny]) {
            vis[nx][ny] = 1;
            dfs(nx, ny);
        }
    }
}
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> t;
	while (t --) {
		cin >> n;
		memset(a, 0, sizeof(a));
        memset(vis, 0, sizeof(vis));
		b = 0;
		for (int i = 1; i <= 2; i ++) 
			for (int j = 1; j <= n; j ++) {
				cin >> a[i][j];
			}
		dfs(1, 1);
        if (b) 
            cout << "YES\n";
        else 
            cout << "NO\n";
	}
	return 0;
}
T5

T638238 传送门

赛时得分&代码
Accepted1̸00tps\color{green}{Accepted\not100tps}
C++
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int N = 5e5 + 5;
int n, x, y, cnt, ans = 1;
map<int, int> a, b, vis;
vector<int> g[N];
void dfs(int u) {
    ans = max(ans, b[u]);
    for (int i = 0; i < g[u].size(); i ++) {
        int v = g[u][i];
        if (vis[v] == 1) 
            continue;
        vis[v] = 1;
        dfs(v);
    }
}
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> x >> y;
        if (a.count(x) == 0) {
            a[x] = ++ cnt;
            b[cnt] = x;
        }
        if (a.count(y) == 0) {
            a[y] = ++ cnt;
            b[cnt] = y;
        }
        g[a[x]].push_back(a[y]);
        g[a[y]].push_back(a[x]);
	}
    dfs(a[1]);
	cout << ans;
	return 0;
}
原文