9.16
L_xiang365 · · 个人记录
一、比赛基本情况
比赛日期:9.17
比赛时长:3小时
比赛得分:200
比赛排名:26
二、比赛整体回顾
简要记录本场比赛的做题顺序、时间安排、比赛状态以及整体感受。
5 -> 1 -> 2 -> 3 -> 4 (看了6题)
5 : 30时间
2 : 30时间
剩下没Accepted
三、题目复盘
T1:____A - Pipes____
本题得分:0
开始时间:2:45
结束时间:3:20
总用时:35
初始思路
无
赛后题解
因为直岛和弯道
所以
- a[x][y] == 0 (x + 1, y)
- a[x][!y] && a[x][y] (x + 1, !y)
枚举到n + 1
补题代码
#include<bits/stdc++.h>
using namespace std;
int n, p;
int const N = 2e5 + 5;
int a[N][2];
void dfs(int x, int y){
if(x == n + 1 && y == 1){
p = 1;
return;
}
if(x == n + 1) return;
// if(p) return;
if(!a[x][y]) dfs(x + 1, y);
else{
if(a[x][!y]){
dfs(x + 1, !y);
}
}
}
void solve(){
p = 0;
cin >> n;
for(int i = 1; i <= n; i++){
char c;
cin >> c;
a[i][0] = (c >= '3');
}
for(int i = 1; i <= n; i++){
char c;
cin >> c;
a[i][1] = (c >= '3');
}
dfs(1, 0);
if(p) cout << "YES";
else cout << "NO";
cout << "\n";
}
int main(){
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
复杂度
时间复杂度:
空间复杂度:
本题总结
T2:____B - Quests____
本题得分:Accepted
开始时间:3:20
结束时间:3:35
总用时:15
初始思路
直接二分+模拟+贪心
可以说就是砍树加强3版
考场解题过程
直接做即可
考场代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, c, d;
int const N = 2e5 + 5;
int a[N];
bool check(int mid){
int sum = 0, ct = 0;
mid++;
for(int i = 1; i <= d; i++){
ct++;
if(ct == mid + 1) ct = 1;
if(ct <= n) sum += a[ct];
}
return sum >= c;
}
void solve(){
cin >> n >> c >> d;
for(int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + n + 1, greater<int>());
int l = 0, r = d, ans = -1;
while(l <= r){
int mid = (l + r) / 2;
if(check(mid)) ans = mid, l = mid + 1;
else r = mid - 1;
}
if(ans == d) cout << "Infinity";
else if(ans == -1) cout << "Impossible";
else cout << ans;
cout << "\n";
}
signed main(){
int t;
cin >> t;
while(t--) solve();
return 0;
}
复杂度
时间复杂度:
空间复杂度:
本题总结
T3:____C - Shuffle____
本题得分:0
开始时间:3:35
结束时间:4:20
总用时:45分
初始思路
无
赛后题解
我们发现他有一段,可以直接贪心模拟
补题代码
#include<bits/stdc++.h>
using namespace std;
int n, x, q;
void solve(){
cin >> n >> x >> q;
int al = x, ar = x;
while(q--){
int l, r;
cin >> l >> r;
if(l <= ar && r >= al){
al = min(al, l);
ar = max(ar, r);
}
}
cout << ar - al + 1 << "\n";
}
int main(){
int t = 1;
cin >> t;
while(t--) solve();
}
复杂度
时间复杂度:
空间复杂度:
本题总结
T4:____D - Special Numbers____
本题得分:0
开始时间:4:20
结束时间:4:30
总用时:10
初始思路
考场解题过程
所以
考场代码
没做对,无(未保留)
赛后题解
完全正确
补题代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, k, mod = 1e9 + 7;
void solve(){
cin >> n >> k;
int ans = 0, pw = 1;
for(int i = 0; i <= 30; i++){
if(k & (1 << i)) ans += pw;
// cout << (k & (1 << i)) << " " << pw << "\n";
pw %= mod;
ans %= mod;
pw *= n;
}
cout << ans << "\n";
}
signed main(){
int t = 1;
cin >> t;
while(t--) solve();
}
复杂度
时间复杂度:
空间复杂度:
本题总结
T5:____E - Add One____
本题得分:Accepted
开始时间:2:00
结束时间:2:45
总用时:45分钟
初始思路
老师的状态太难了
状态定义
我们发现对每位增加m次,使得每次增加
考场解题过程
状态转移方程
只有值为
-
i + j \le 9$ : $dp[i][j] = 1 -
i + j \ge 10$ : $dp[i][j] = dp[0][i + j - 10] + dp[1][i + j - 10]
i变成2位按dp状态分析
考场代码
#include<bits/stdc++.h>
using namespace std;
int n, m, mod = 1e9 + 7;
int const N = 2e5 + 5;
int dp[15][N];
void solve(){
cin >> n >> m;
int ans = 0;
while(n){
ans += dp[n % 10][m];
ans %= mod;
n /= 10;
}
cout << ans << "\n";
}
int main(){
int t;
cin >> t;
for(int i = 0; i <= 2e5; i++){
for(int j = 0; j <= 9; j++){
if(i + j <= 9) dp[j][i] = 1;
else dp[j][i] = (dp[0][i + j - 10] + dp[1][i + j - 10]) % mod;
}
}
while(t--) solve();
return 0;
}
复杂度
时间复杂度:
空间复杂度:
本题总结
T6:____F - Mark and His Unfinished Essay____
无
赛后题解
我们发现c较小可以做突破点
我们可以枚计算ln[i], l[i], r[i]来枚举计算
补题代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, c, q;
int const N = 2e5 + 5;
char a[N];
int l[N], r[N], cha[N];
void solve(){
cin >> n >> c >> q;
for(int i = 1; i <= n; i++) cin >> a[i];
int ln = n;
for(int i = 1; i <= c; i++){
cin >> l[i] >> r[i];
cha[i] = ln - l[i] + 1;
ln += r[i] - l[i] + 1;
}
while(q--){
int x;
cin >> x;
for(int i = c; i >= 1; i--){
if(x >= l[i] + cha[i] && x <= r[i] + cha[i]) x -= cha[i];
}
cout << a[x] << "\n";
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
复杂度
时间复杂度:
空间复杂度:
本题总结
四、整体反思
做得较好的地方
无
需要改进的地方
题目时间安排和思维题
时间安排总结
no T4安排的剩余时间不好