当前位置: 首页 > 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.hskmm.com/?act=detail&tid=9985

相关文章:

  • ctfshow web
  • 代码随想录算法训练营第三天 | leetcode 203 707 206
  • Codeforces Round 1051 (Div. 2) A~D2
  • 【F#学习】数组:Array
  • CTFWEB姿势总结
  • 规模化加速AI:从用户、开发者到企业的深度策略解析
  • ctfshow 菜狗杯
  • 国际服务器(VPS):泰国、印尼、菲律宾、马来西亚、香港、台湾、新加坡、日本、美国、英国等。
  • 缓存常见问题
  • ctfshow 电子取证
  • Hello,World!
  • 最新IDEA 2025 专业版破解永久破解教程(附资源)intellij IDEA
  • AtCoder ABC423F - Loud Cicada 题解 容斥原理
  • 1756:八皇后
  • 矩阵置零-leetcode
  • 嘉立创常用快捷键
  • 02020402 EF Core基础02-EF Core数据的增删改查
  • conda 无法安装依赖 CondaHTTPError: HTTP 000 CONNECTION FAILED for url: tsinghua tencentaliyun
  • 牛客刷题-Day2
  • 图解支付系统账务系统核心设计 - 智慧园区
  • vulnhub(持续更新)
  • 小爱同学连接电脑进行交互 教程
  • 网络流初步浅谈:EK与Dinic
  • 解码C语言结构体
  • 已完成今日求所有满足长为 $a$ 的和为 $b$ 的按位或为 $c$ 的非负整数序列的异或和的异或和大学习
  • Hello Yqc!
  • 2025.9.19——卷9-10选择
  • 软件工程学习日志2025.9.19
  • ECT-OS-JiuHuaShan 框架元推理,是人类良医与福音
  • upload-labs全通关