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

U522155 板垣 カノエ is WATCHING YOU std

U522155 板垣 カノエ is WATCHING YOU

#include<bits/stdc++.h>
#define int long long 
#define add(a,b) to[++ tot] = b,nxt[tot] = h[a],h[a] = tot
#define con putchar_unlocked(' ')
#define ent putchar_unlocked('\n')
#define Blue_Archive return 0
using namespace std;
constexpr int N = 1e5 + 3;
constexpr int M = 2e5 + 3;
constexpr int INF = 1e18;
constexpr char me[] = "終末なにしてますか?忙しいですか?救ってもらっていいですか?";int n;
int st;
int cnt;
int tot;
int h[N];
int to[M];
int nxt[M];
int dis[N];
bool vis[N];string s;map<string,int> mp;priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;inline int read()
{int k = 0,f = 1;char c = getchar_unlocked();while(c < '0' || c > '9'){if(c == '-') f = -1;c = getchar_unlocked();} while(c >= '0' && c <= '9') k = (k << 3) + (k << 1) + c - '0',c = getchar_unlocked();return k * f;
}inline void write(int x)
{if(x < 0) putchar_unlocked('-'),x = -x;if(x > 9) write(x / 10);putchar_unlocked(x % 10 + '0');
}inline void dijk()
{for(int i = 1;i <= cnt;i ++) dis[i] = INF;q.push({dis[st],st});vis[st] = 1;dis[st] = 0;while(!q.empty()){int u = q.top().second;q.pop();for(int i = h[u];i;i = nxt[i]){if(dis[to[i]] > dis[u] + 1){dis[to[i]] = dis[u] + 1;if(!vis[to[i]]){q.push({dis[to[i]],to[i]});vis[to[i]] = 1;}}}}
}signed main()
{// freopen("data.in","r",stdin);freopen("data.out","w",stdout);n = read();for(int i = 1,m,x,las;i <= n;i ++){m = read();for(int j = 1;j <= m;j ++){cin >> s;if(!mp[s]) mp[s] = x = ++ cnt;else x = mp[s];if(j != 1) add(x,las);las = x;}}cin >> s;st = mp[s];dijk();int q = read();while(q --){cin >> s;write(dis[mp[s]]);ent;}Blue_Archive;
}
http://www.rkmt.cn/news/8267.html

相关文章:

  • ctfshow web
  • 代码随想录算法训练营第三天 | leetcode 203 707 206
  • 【F#学习】数组:Array
  • ctfshow 菜狗杯
  • 详细介绍:测试用例详解
  • conda 无法安装依赖 CondaHTTPError: HTTP 000 CONNECTION FAILED for url: tsinghua tencentaliyun
  • vulnhub(持续更新)
  • 小爱同学连接电脑进行交互 教程
  • 已完成今日求所有满足长为 $a$ 的和为 $b$ 的按位或为 $c$ 的非负整数序列的异或和的异或和大学习
  • 集群无法启动CRS-4124: Oracle High Availability Services startup failed - 指南
  • Hello Yqc!
  • SAPO去中心化训练:多节点协作让LLM训练效率提升94%
  • 区间问题
  • 解决 Ubuntu 25.04 下 make menuconfig 报 ncurses 错误的问题 - 指南
  • web359
  • 如何在后端优雅地生成并传递动态错误提示?
  • web358
  • WPF包
  • 实用指南:目标检测如何将同时有方形框和旋转框的json/xml标注转为txt格式
  • ctfshow web351
  • Linux虚拟机常用命令与Hadoop生态组件启动大全
  • private void Form1_Load与构造方法前执行顺序
  • HarmonyOS Stage模型与ArkTS:现代应用开发的核心架构与最佳实践 - 详解
  • 完整教程:构建基石:Transformer架构
  • 【先记录一下】windows下使用的lazarus/fpc安装到中文的目录时出错的问题
  • CF182C Optimal Sum
  • HTB UNIV CTF 24 Armaxix靶场漏洞链:命令注入与账户接管实战
  • PyTorch Weight Decay 技术指南
  • js获取浏览器语言,以及调用谷歌翻译api翻译成相应的内容
  • The 2025 ICPC Asia EC Regionals Online Contest (II)