当前位置:网站首页>Niuniu's ball guessing game (dynamic planning + prefix influence)
Niuniu's ball guessing game (dynamic planning + prefix influence)
2022-07-03 01:41:00 【MangataTS】
Topic linking
https://ac.nowcoder.com/acm/contest/19483/F
Topic

Ideas
We use one f [ i ] [ j ] f[i][j] f[i][j] It means the first one i No. of operations j A ball in a cup , Because we constantly exchange cups , So we will have a prefix effect , So every time we pass directly r r r and l − 1 l-1 l−1 Just make a mapping
Code
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int dp[N][10];
int a[10];
int n,m;
int main()
{
scanf("%d%d",&n,&m);
int A,B;
for(int i = 0;i < 10; ++i) dp[0][i] = i;
for(int i = 1;i <= n; ++i) {
scanf("%d%d",&A,&B);
for(int j = 0;j < 10; ++j) {
dp[i][j] = dp[i-1][j];
}
swap(dp[i][A],dp[i][B]);
}
while(m--) {
scanf("%d%d",&A,&B);
for(int i = 0;i < 10; ++i) {
a[dp[A-1][i]] = i;
}
for(int i = 0;i < 10; ++i) {
printf("%d%c",a[dp[B][i]],i==9?'\n':' ');
}
}
return 0;
}
边栏推荐
- After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-9
- Tâche 6: regroupement DBSCAN
- [QT] encapsulation of custom controls
- The thread reuse problem of PageHelper using ThreadLocal, did you use it correctly?
- NCTF 2018 part Title WP (1)
- 看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9
- 什么是调。调的故事
- Uniapp component -uni notice bar notice bar
- How is the mask effect achieved in the LPL ban/pick selection stage?
- The difference between tail -f, tail -f and tail
猜你喜欢

【数据挖掘】任务3:决策树分类
![[data mining] task 1: distance calculation](/img/72/a63cdfe32a7c438acf48a069d9bba1.png)
[data mining] task 1: distance calculation

leetcode刷题_两数之和 II - 输入有序数组

【數據挖掘】任務6:DBSCAN聚類

Main features of transport layer TCP and TCP connection

Pytest learning notes (12) -allure feature · @allure Step () and allure attach

Installation and use of serial port packet capturing / cutting tool
![[data mining] task 6: DBSCAN clustering](/img/af/ad7aa523b09884eee967c6773a613f.png)
[data mining] task 6: DBSCAN clustering

看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9

C application interface development foundation - form control (3) - file control
随机推荐
Three core issues of concurrent programming - "deep understanding of high concurrent programming"
Druid database connection pool
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
[QT] encapsulation of custom controls
STM32 - vibration sensor control relay on
Vim 9.0正式发布!新版脚本执行速度最高提升100倍
After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-9
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
网络安全-openvas
网络安全-扫描与密码爆破2
Learn the five skills you need to master in cloud computing application development
Wordinsert formula /endnote
传输层 TCP主要特点和TCP连接
MySQL - database query - basic query
How is the mask effect achieved in the LPL ban/pick selection stage?
What is tone. Diao's story
LDC Build Shared Library
C application interface development foundation - form control (1) - form form
网络安全-DNS欺骗与钓鱼网站
MySQL - database query - condition query