2026.03.23
测试情况
| 题目 | 估分 | 实际 |
|---|---|---|
| 总分 |
今天没挂分!!!
A
题意
给定 NSC 商店和其他
求这
思路
模拟。每次更新最小值,最后通过
时间复杂度为
::::success[AC code]
/*
writer:akaryan
*/
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define Int __int128
#define db double
#define ldb long double
#define inf (1 << 30)
#define INF (1LL << 60LL)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define bug(x) cout << #x << " = " << x << '\n'
using namespace std;
const int N = 2e5 + 10 , M = 2e5 + 10;
const int mod = 998244353;
int n , x , y , a , b , now , now2;
inline void solve(){
cin >> x >> y >> n;
while(n --) cin >> a >> b , now = a * y , now2 = b * x , x = ((now < now2) ? a : x) , y = ((now < now2) ? b : y);//更新最小值
cout << fixed << setprecision(2) << (db)(1.0 * x / y * 1000) << '\n';//求1000克肉肠的价格
}
int main(){
ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
solve();
return 0;
}
::::
B
题意
给定一个长度为 + 表示第 - 表示第 = 表示第
- 如果第
i 天的净资产上涨,他会在当天开始时的净资产对应的行画/。 - 如果第
i 天的净资产下跌,他会在当天开始时的净资产对应的行画\。 - 如果第
i 天的净资产不变,他会在当天开始时的净资产对应的行画-。
求矩阵大小最小的公司资产的变化示意图。
思路
用
因为资产值可能有变化,所以我们需要知道最高行和最低行,才能确定矩阵范围。
每天根据符号,在数组的第
最后从最高行到最低行输出矩阵即可。
:::warning[Trick]
由于
时间复杂度约为
::::success[AC code]
/*
writer:akaryan
*/
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define Int __int128
#define db double
#define ldb long double
#define inf (1 << 30)
#define INF (1LL << 60LL)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define bug(x) cout << #x << " = " << x << '\n'
using namespace std;
const int N = 2e5 + 10 , M = 2e5 + 10;
const int mod = 998244353;
ll n , x , y = 1145141919 , pos = 110;
string s;
char ch[N][N];
inline void solve(){
cin >> n >> s , s = ' ' + s , memset(ch , '.' , sizeof(ch));
for (int i = 1 ; i <= n ; i ++){
if (s[i] == '+') x = max(x , pos) , y = min(y , pos) , ch[pos ++][i] = '/';//资产上涨
else if (s[i] == '-') ch[-- pos][i] = '\\' , x = max(x , pos) , y = min(y , pos);//资产下跌
else if (s[i] == '=') x = max(x , pos) , y = min(y , pos) , ch[pos][i] = '_';//资产不变
}
for (int i = x ; i >= y ; i --){
for (int j = 1 ; j <= n ; j ++) cout << ch[i][j];
cout << '\n';
}
}
int main(){
ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
solve();
return 0;
}
::::
C
题意
给定一个
思路
BFS 板板题。
和二维的 BFS 差不多,区别就在于多了一维和不能斜着走。
时间复杂度为
::::success[AC code]
/*
writer:akaryan
*/
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define Int __int128
#define db double
#define ldb long double
#define inf (1 << 30)
#define INF (1LL << 60LL)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define bug(x) cout << #x << " = " << x << '\n'
using namespace std;
const int N = 2e5 + 10 , M = 2e5 + 10;
const int mod = 998244353;
const int dx[] = {1 , -1 , 0 , 0 , 0 , 0} , dy[] = {0 , 0 , 1 , -1 , 0 , 0} , dz[] = {0 , 0 , 0 , 0 , 1 , -1};
ll n , sx , sy , sz , ex , ey , ez , dis[N][N][N];
char a[N][N][N];
bool vis[N][N][N];
struct Node{
ll x , y , z;
};
queue<Node> q;
inline void bfs(){//bfs求[sx,sy,sz]到[ex,ey,ez]的最短距离
q.push({sx , sy , sz}) , dis[sx][sy][sz] = 0;
while(!q.empty()){
auto x = q.front();
q.pop();
for (int i = 0 ; i < 6 ; i ++){
ll nx = x.x + dx[i] , ny = x.y + dy[i] , nz = x.z + dz[i];
if (nx >= 1 && nx <= n && ny >= 1 && ny <= n && nz >= 1 && nz <= n && !vis[nx][ny][nz]) dis[nx][ny][nz] = dis[x.x][x.y][x.z] + 1 , vis[nx][ny][nz] = 1 , q.push({nx , ny , nz});
}
}
}
inline void solve(){
cin >> n >> sx >> sy >> sz >> ex >> ey >> ez;
for (int k = 1 ; k <= n ; k ++) for (int i = 1 ; i <= n ; i ++) for (int j = 1 ; j <= n ; j ++) cin >> a[i][j][k] , vis[i][j][k] = (a[i][j][k] - '0') , dis[i][j][k] = INF;
bfs() , cout << ((dis[ex][ey][ez] == INF) ? -1 : dis[ex][ey][ez]) << '\n';
}
int main(){
ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
solve();
return 0;
}
::::
D
题意
给定
思路
由于我们想让课能持续的时间最长,那么选择刚好
将所有学生的时段按
最后
时间复杂度为
::::success[AC code]
/*
writer:akaryan
*/
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define Int __int128
#define db double
#define ldb long double
#define inf (1 << 30)
#define INF (1LL << 60LL)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define bug(x) cout << #x << " = " << x << '\n'
using namespace std;
const int N = 3e5 + 10 , M = 2e5 + 10;
const int mod = 998244353;
ll n , k , ans;
priority_queue<ll , vector<ll> , greater<ll>> q;//维护小根堆
struct Node{
ll l , r;
}a[N];
inline void solve(){
cin >> n >> k;
for (int i = 1 ; i <= n ; i ++) cin >> a[i].l >> a[i].r;
sort(a + 1 , a + n + 1 , [&](const Node &x , const Node &y){return x.l < y.l;});//按左端点排序
for (int i = 1 ; i <= n ; i ++){
q.push(a[i].r);
if (q.size() > k) q.pop();
if (q.size() == k && q.top() >= a[i].l) ans = max(ans , q.top() - a[i].l);
}
cout << ans << '\n';
}
int main(){
ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
solve();
return 0;
}
::::
后记
帮 ggy 调题,调到我晚上