T1

传送门

解题思路

这似乎是小学数学知识???mod 9就相当于各位之和mod 9,打表求了个逆元,等差数列求和公式就行了。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath> using namespace std;
typedef long long LL; inline LL rd(){
LL x=,f=;char ch=getchar();
while(!isdigit(ch)) {f=ch=='-'?:;ch=getchar();}
while(isdigit(ch)) {x=(x<<)+(x<<)+ch-'';ch=getchar();}
return f?x:-x;
} LL l,r;
int q; int main(){
scanf("%d",&q);
while(q--){
l=rd(),r=rd();
printf("%lld\n",(r-l+)%*(l%+r%)%*%);
}
return ;
}

T2

传送门

解题思路

最短路,求出哈利在1点与T1点到其他点的最短路,再求出罗恩在一点与T1点到其他点的最短路,然后分类讨论就行了。

// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue> using namespace std;
const int MAXN = ;
const int MAXM = ; inline int rd(){
int x=,f=;char ch=getchar();
while(!isdigit(ch)) {f=ch=='-'?:;ch=getchar();}
while(isdigit(ch)) {x=(x<<)+(x<<)+ch-'';ch=getchar();}
return f?x:-x;
} int n,m,head[MAXN],cnt,k,T1,T2,ans;
int to[MAXM<<],nxt[MAXM<<],val[MAXM<<];
int dis[MAXN][]; //dis[x][1] 哈利1 dis[x][2] 罗恩1 dis[x][3] 哈利x dis[x][4] 罗恩x
bool lim[MAXN],vis[MAXN];
queue<int> Q; inline void add(int bg,int ed,int w){
to[++cnt]=ed,nxt[cnt]=head[bg],val[cnt]=w,head[bg]=cnt;
} void spfa_Harry(int st,int now){
memset(vis,false,sizeof(vis));
dis[st][now]=;Q.push(st);vis[st]=;
register int x,u;
while(!Q.empty()){
x=Q.front();Q.pop();vis[x]=;
for(register int i=head[x];i;i=nxt[i]){
u=to[i];
if(dis[x][now]+val[i]<dis[u][now]){
dis[u][now]=dis[x][now]+val[i];
if(!vis[u]){vis[u]=;Q.push(u);}
}
}
}
} void spfa_Ron(int st,int now){
memset(vis,false,sizeof(vis));
dis[st][now]=;vis[st]=;Q.push(st);
int x,u;
while(!Q.empty()){
x=Q.front();Q.pop();vis[x]=;
for(register int i=head[x];i;i=nxt[i]){
u=to[i];if(lim[u]) continue;
if(dis[x][now]+val[i]<dis[u][now]){
dis[u][now]=dis[x][now]+val[i];
if(!vis[u]) {vis[u]=;Q.push(u);}
}
}
}
} int main(){
memset(dis,0x3f,sizeof(dis));
n=rd(),m=rd(),k=rd();int x,y,z;
for(int i=;i<=k;i++) lim[rd()]=;
for(int i=;i<=m;i++){
x=rd(),y=rd(),z=rd();
add(x,y,z),add(y,x,z);
}
T1=rd(),T2=rd();
spfa_Harry(,);spfa_Harry(T1,);
spfa_Ron(,);spfa_Ron(T1,);
ans=min(min(max(dis[T1][],dis[T2][]),max(dis[T2][],dis[T1][]))
,min(min(dis[T1][],dis[T2][])+dis[T2][],min(dis[T1][],dis[T2][])+dis[T2][]));
cout<<ans<<endl;
return ;
}

T3

传送门

解题思路

大模拟,感觉没有时间复杂度难。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<algorithm> using namespace std;
const int MAXN = ; int n,m,c,k,cnt,mp[MAXN][MAXN];
int hx[MAXN],hy[MAXN],food,wx[MAXN],wy[MAXN];
int sx[]={,,-,},sy[]={-,,,};
bool exist[MAXN];
char s[MAXN][MAXN],zz[MAXN][MAXN]; struct Snack{
int num,len;
}S[MAXN]; void dfs(int x,int y){
S[cnt].len++;
mp[x][y]=cnt;bool flag=;
for(register int i=;i<=;i++){
int xx=x+sx[i],yy=y+sy[i];
if(xx<= || xx>n || yy<= || yy>m) continue;
if(s[xx][yy]!='#' || mp[xx][yy]==cnt) continue;
flag=;dfs(xx,yy);
}
if(!flag) wx[cnt]=x,wy[cnt]=y;
} void die(int x,int y,int id){
mp[x][y]=-;
for(register int i=;i<=;i++){
int xx=x+sx[i],yy=y+sy[i];
if(xx<= || xx>n || yy<= || yy>m) continue;
if(mp[xx][yy]!=id) continue;
die(xx,yy,id);
}
} inline bool pd(int x,int y){
if(x> && x<=n && y> && y<=m && mp[x][y]<=) return true;
return false;
} inline bool cmp(Snack A,Snack B){
if(A.len==B.len) return A.num<B.num;
return A.len>B.len;
} int main(){
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=n;i++) scanf("%s",s[i]+);
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
if(s[i][j]=='&') mp[i][j]=-,food++;
if(s[i][j]=='@'){
cnt++;
hx[cnt]=i,hy[cnt]=j;
dfs(i,j);exist[cnt]=;
S[cnt].num=cnt;
}
}
}
// for(int i=1;i<=n;i++){
// for(int j=1;j<=m;j++)
// cout<<mp[i][j]<<" ";
// cout<<endl;
// }
for(int i=;i<=cnt;i++)
scanf("%s",zz[i]+);
for(int i=;i<=k;i++)
for(int j=;j<=cnt;j++){
if(!exist[j]) continue;
if(zz[j][i]=='D') {
hy[j]++;
if(!pd(hx[j],hy[j])) {
die(hx[j],hy[j]-,j);
food+=S[j].len;
exist[j]=;S[j].len=;
continue;
}
if(mp[hx[j]][hy[j]]==-){
food--;S[j].len++;
mp[hx[j]][hy[j]]=j;
continue;
}
mp[hx[j]][hy[j]]=j;
for(register int t=;t<=;t++){
int xx=wx[j]+sx[t],yy=wy[j]+sy[t];
if(mp[xx][yy]==j) {
mp[wx[j]][wy[j]]=;
wx[j]=xx,wy[j]=yy;
break;
}
}
}
if(zz[j][i]=='A') {
hy[j]--;
if(!pd(hx[j],hy[j])) {
die(hx[j],hy[j]+,j);
food+=S[j].len;
exist[j]=;S[j].len=;
continue;
}
if(mp[hx[j]][hy[j]]==-){
food--;S[j].len++;
mp[hx[j]][hy[j]]=j;
continue;
}
mp[hx[j]][hy[j]]=j;
for(register int t=;t<=;t++){
int xx=wx[j]+sx[t],yy=wy[j]+sy[t];
if(mp[xx][yy]==j) {
mp[wx[j]][wy[j]]=;
mp[xx][yy]=;
wx[j]=xx,wy[j]=yy;
break;
}
}
}
if(zz[j][i]=='W') {
hx[j]--;
if(!pd(hx[j],hy[j])) {
die(hx[j]+,hy[j],j);
food+=S[j].len;
exist[j]=;S[j].len=;
continue;
}
if(mp[hx[j]][hy[j]]==-){
food--;S[j].len++;
mp[hx[j]][hy[j]]=j;
continue;
}
mp[hx[j]][hy[j]]=j;
for(register int t=;t<=;t++){
int xx=wx[j]+sx[t],yy=wy[j]+sy[t];
if(mp[xx][yy]==j) {
mp[wx[j]][wy[j]]=;
mp[xx][yy]=;
wx[j]=xx,wy[j]=yy;
break;
}
}
}
if(zz[j][i]=='S') {
hx[j]++;
if(!pd(hx[j],hy[j])) {
die(hx[j]-,hy[j],j);
food+=S[j].len;
exist[j]=;S[j].len=;
continue;
}
if(mp[hx[j]][hy[j]]==-){
food--;S[j].len++;
mp[hx[j]][hy[j]]=j;
continue;
}
mp[hx[j]][hy[j]]=j;
for(register int t=;t<=;t++){
int xx=wx[j]+sx[t],yy=wy[j]+sy[t];
if(mp[xx][yy]==j) {
mp[wx[j]][wy[j]]=;
mp[xx][yy]=;
wx[j]=xx,wy[j]=yy;
break;
}
}
}
}
sort(S+,S++cnt,cmp);
// for(int i=1;i<=n;i++){
// for(int j=1;j<=m;j++)
// cout<<mp[i][j]<<" ";
// cout<<endl;
// }
for(int i=;i<=cnt;i++)
printf("%d %d\n",S[i].len,S[i].num);
printf("%d",food);
return ;
}

LUOGU NOIP 2018 模拟赛 DAY1的更多相关文章

  1. 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...

  2. 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...

  3. 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...

  4. CH Round #48 - Streaming #3 (NOIP模拟赛Day1)

    A.数三角形 题目:http://www.contesthunter.org/contest/CH%20Round%20%2348%20-%20Streaming%20%233%20(NOIP模拟赛D ...

  5. CH Round #54 - Streaming #5 (NOIP模拟赛Day1)

    A.珠 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2354%20-%20Streaming%20%235%20(NOIP模拟赛Day1)/珠 题解:sb题, ...

  6. NOIP前模拟赛总结

    NOIP前模拟赛总结 from 2018.10.7 to ??? Date Name Score(Rank) Problems 2018.10.7 McfXH AK Contest 42(?) 期望得 ...

  7. 10.17(山东多校联合模拟赛 day1)

    山东多校联合模拟赛 day1 题不难 rect [问题描述] 给出圆周上的 N 个点, 请你计算出以这些点中的任意四个为四个角,能构成多少个矩形. 点的坐标是这样描述的, 给定一个数组 v[1..N] ...

  8. PKUSC 模拟赛 day1 下午总结

    下午到了机房之后又困又饿,还要被强行摁着看英文题,简直差评 第一题是NOIP模拟赛的原题,随便模拟就好啦 本人模拟功力太渣不小心打错了个变量,居然调了40多分钟QAQ #include<cstd ...

  9. NOIP一系列模拟赛小结

    NOIP越发接近了,于是自己也跟着机房的几位师兄一起做了几次NOIP模拟赛,收获颇多. #1-T1:求点集中的点能否只用三条与坐标轴平行的直线就能全部被经过,其实只要将横纵坐标排序后逐个点检查下就行. ...

随机推荐

  1. kubernetes istio的快速安装和使用例子

    安装 [root@master ~]# wget https://github.com/istio/istio/releases/download/1.1.5/istio-1.1.5-linux.ta ...

  2. bzoj 1196: [HNOI2006]公路修建问题(二分+贪心)

    传送门 解题思路 看到最大,肯定要先想二分答案.二分之后首先从小到大枚举\(k\)个小于\(lim\)的所有一级公路,然后用并查集连到一起,然后就在剩下的里面从小到大找n-1-k个二级公路,模仿最小生 ...

  3. System.Web.HttpSessionStateBase.cs

    ylbtech-System.Web.HttpSessionStateBase.cs 1.程序集 System.Web, Version=4.0.0.0, Culture=neutral, Publi ...

  4. 记录一次hexo托管到coding失败,页面总是404,可是相同的代码托管到github是没问题的。

    文章目录 问题描述: 问题原因: 问题解决 2019.1.23 问题,coding又挂了. 弃疗 个人博客:https://mmmmmm.me 源码:https://github.com/dataiy ...

  5. 可拖拽排序的vue组件

    最近在优化一个vue的博客系统,想实现文章列表处的文章拖拽功能.就试了一下awe-dnd vue插件,觉得还挺好用的. 安装 npm install awe-dnd --save 使用 在main.j ...

  6. 正则表达式r和re

    # coding:utf-8 import re print 'a\ws' print r'a\nb' # r'': 一般用在正则表达式中,称为原始字符串,作用是将Python语法中的反斜杠转义给 取 ...

  7. CCPC 2019 网络赛 HDU huntian oy (杜教筛)

    1005 huntian oy (HDU 6706) 题意: 令,有T次询问,求 f(n, a, b). 其中 T = 10^4,1 <= n,a,b <= 1e9,保证每次 a,b互质. ...

  8. vue-router使用入门

    安装及基本配置 # 安装 npm install vue-router # 使用 import Vue from 'vue' import VueRouter from 'vue-router' Vu ...

  9. 初识OpenCV-Python - 004: Trackbar as the color palette

    此次学习了如何用OpenCV建立一个色调盘.其中会用到cv2.getTrackbarPos(), cv2.createTrackbar()函数. code: import cv2import nump ...

  10. Hadoop2.7.1配置NameNode+ResourceManager高可用原理分析

    关于NameNode高可靠需要配置的文件有core-site.xml和hdfs-site.xml 关于ResourceManager高可靠需要配置的文件有yarn-site.xml 逻辑结构: Nam ...