当前位置: 首页 > news >正文

NOIP 模拟赛 9

NOIP 模拟赛总结

NOIP 模拟赛 9

调了一整场的 T2,样例全过!只有 40 pts。QxQ

T1 卡门

连续两场 T1 放数据结构了欸

数据结构题,直接分块就行。

赛时没算时间复杂度,导致打了个暴力交上去以为是正解。

赛后半小时改完,挂挂挂!

点击查看代码
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cmath>
#define con putchar_unlocked(' ')
#define ent putchar_unlocked('\n')
#define Blue_Archive return 0
using namespace std;
constexpr int N = 3e4 + 3;
constexpr int B = 175;
constexpr int M = 31;
constexpr int me = 0x0d000721;int n;	
int m;
int K;
int ans;
int len;
int L[B];
int R[B];
int id[N];pair<int,int> to[B][M];int mp[N][M];inline void dfs_init(int x,int y,int dep,pair<int,int>&op)
{if(x == dep) return void(op = {x,y});if(!mp[x + 1][y]) dfs_init(x + 1,y,dep,op);else if(mp[x + 1][y] == 2){if(y > 1 && !mp[x][y - 1] && !mp[x + 1][y - 1]) dfs_init(x,y - 1,dep,op);else if(y < m && !mp[x][y + 1] && !mp[x + 1][y + 1]) dfs_init(x,y + 1,dep,op);else return void(op = {x,y});}else return void(op = {x,y});
}inline void init()
{int len = sqrt(n);for(int i = 1;i <= n;i ++){id[i] = (i - 1) / len + 1;if(!L[id[i]]) L[id[i]] = i;R[id[i]] = i;}for(int i = 1;i < id[n];i ++){for(int j = 1;j <= m;j ++){dfs_init(L[i],j,R[i] + 1,to[i][j]);}}for(int i = 1;i <= m;i ++) dfs_init(L[id[n]],i,n,to[id[n]][i]);
}inline void query(int x)
{int now = x;int op = 0;for(int i = 1;i <= id[n];i ++){if(to[i][now].first != R[i] + 1) break;op = i;now = to[i][now].second;}op ++;mp[to[op][now].first][to[op][now].second] = 2;if(to[op][now].first == L[op]){for(int i = 1;i <= m;i ++){if(to[op - 1][i].first == L[op] && to[op - 1][i].second == to[op][now].second) dfs_init(L[op - 1],i,R[op - 1] + 1,to[op - 1][i]);}}for(int i = 1;i <= m;i ++){dfs_init(L[op],i,min(R[op] + 1,n),to[op][i]);}
}signed main()
{freopen("kamen.in","r",stdin);freopen("kamen.out","w",stdout);// freopen("data.in","r",stdin);freopen("data.out","w",stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n >> m;char op;for(int i = 1;i <= n;i ++){for(int j = 1;j <= m;j ++){cin >> op;mp[i][j] = (op == '.') ? 0 : 1;}}init();cin >> K;for(int i = 1,x;i <= K;i ++){cin >> x;query(x);}for(int i = 1;i <= n;i ++){for(int j = 1;j <= m;j ++){if(mp[i][j] == 0) cout << '.';else if(mp[i][j] == 1) cout << 'X';else if(mp[i][j] == 2) cout << 'O';}cout << '\n';}Blue_Archive;
}

T2 商人

5 个样例全过,只得 40 pts,qwq。

考虑建反图

点击查看代码
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <queue>
#define int long long 
#define add(u,v) to[++ tot] = v,nxt[tot] = h[u],h[u] = tot
#define con putchar_unlocked(' ')
#define ent putchar_unlocked('\n')
#define Blue_Archive return 0
using namespace std;
constexpr int N = 2e5 + 3;
constexpr int me = 0x0d00721;
constexpr int INF = 1e9;int n;
int m;
int tot;
int h[N];
int in[N];
int to[N];
int nxt[N];
int ans[N];bitset<N> vis;queue<int> q;struct miku
{int x,y,r,p;friend bool operator < (miku a,miku b){return a.r < b.r;}
}eg[N];signed main()
{freopen("merchant.in","r",stdin);freopen("merchant.out","w",stdout);// freopen("data.in","r",stdin);freopen("data.out","w",stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n >> m;for(int i = 1,x,y,r,p;i <= m;i ++){cin >> x >> y >> r >> p;eg[i] = {x,y,r,p};in[x] ++;}memset(ans,0x3f,sizeof(ans));sort(eg + 1,eg + m + 1);for(int i = 1;i <= m;i ++) add(eg[i].y,i);for(int i = 1;i <= n;i ++) if(!in[i]) q.push(i);for(int i = m;i >= 1;i --){while(!q.empty()){int u = q.front();q.pop();for(int j = h[u];j;j = nxt[j]){if(vis[to[j]]) continue;vis[to[j]] = 1;-- in[eg[to[j]].x];if(!in[eg[to[j]].x]) q.push(eg[to[j]].x);if(ans[u] < INF) ans[eg[to[j]].x] = min(ans[eg[to[j]].x],max(eg[to[j]].r,ans[u] - eg[to[j]].p));}}if(!vis[i]){vis[i] = 1;-- in[eg[i].x];if(!in[eg[i].x]) q.push(eg[i].x);ans[eg[i].x] = min(ans[eg[i].x],eg[i].r);}}for(int i = 1;i <= n;i ++) cout << ((ans[i] > INF) ? -1 : ans[i]) << ' ';Blue_Archive;
}

T3:自行车

不会,咕咕。

T4: 记忆

不会,咕咕。

http://www.jsqmd.com/news/43061/

相关文章:

  • Sora 2 Cameo多角色上传+Remix二创功能API接入教程,史低0.08/条
  • info linux
  • AWS云服务深度集成
  • httpd linux 启动
  • 浅谈 Manacher
  • 第28天(简单题中等题 二分查找)
  • 基于MIMO系统的SCMA稀疏码多址接入和MPA消息传递算法matlab仿真
  • Node.js服务稳定性保障:从热更新到高可用体系
  • 一次尝试,3个小时90元的主机游玩和F1电影
  • NOIP 模拟赛 8
  • 静态路由的配置
  • 读书笔记:“外部表”的进阶使用,它主要解决了三个核心问题:如何切换文件、多用户怎么办,以及一个非常酷的玩法——把系统命令变成表。
  • [CF 2166D] Marble Council
  • DP 复习
  • 一段话 UOJ
  • PG系列:在 ​​psql​​ 客户端中定义参数与动态赋值
  • CF1375G Tree Modification 题解
  • AI评价11月17号
  • 避雷:aicodemirror.com --- 酒干倘卖无
  • 9-线性学习
  • AT AGC003 题解
  • Oracle故障处理:aix 5.3 ml6安装10.2.0.1 rac报错
  • Hive SQL循环与MapReduce的关系
  • 《算 设》学
  • [GESP202506 二级] 幂和数
  • hive mybatis是否支持动态SQL
  • 一类将度数变为 1/2 的优化建图 笔记
  • 2025.11.17模拟赛
  • 11/17
  • 英语_阅读_Electric cars_待读