当前位置:网站首页>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;
}
边栏推荐
- 海量数据冷热分离方案与实践
- Common English Vocabulary
- Vant implements a simple login registration module and a personal user center
- Arduino dy-sv17f automatic voice broadcast
- How is the mask effect achieved in the LPL ban/pick selection stage?
- NCTF 2018 part Title WP (1)
- 力扣 204. 计数质数
- 數學知識:臺階-Nim遊戲—博弈論
- [shutter] animation animation (the core class of shutter animation | animation | curvedanimation | animationcontroller | tween)
- Mathematical knowledge: Nim game game theory
猜你喜欢

Using tensorboard to visualize the model, data and training process
![[data mining] task 4:20newsgroups clustering](/img/76/af1d1338c468ec4825fe12816b84ff.png)
[data mining] task 4:20newsgroups clustering

Why is it not recommended to use BeanUtils in production?

Scheme and practice of cold and hot separation of massive data

wirehark数据分析与取证A.pacapng

Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
![[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array](/img/2a/98400b0d0b5eda1e52abae30746f2b.jpg)
[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array

STM32 - switch of relay control lamp
![[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge](/img/ed/23331d939c9338760e426d368bfd5f.png)
[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge

C application interface development foundation - form control (3) - file control
随机推荐
C#应用程序界面开发基础——窗体控制(3)——文件类控件
Pytest learning notes (12) -allure feature · @allure Step () and allure attach
网络安全-DNS欺骗与钓鱼网站
Why can't the start method be called repeatedly? But the run method can?
Dotconnect for PostgreSQL data provider
PS去除水印详解
【数据挖掘】任务4:20Newsgroups聚类
一位苦逼程序员的找工作经历
What operations need attention in the spot gold investment market?
How is the mask effect achieved in the LPL ban/pick selection stage?
C language course information management system
STM32 - GPIO input / output mode
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
【数据挖掘】任务5:K-means/DBSCAN聚类:双层正方形
C#应用程序界面开发基础——窗体控制(4)——选择类控件
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
Tp6 fast installation uses mongodb to add, delete, modify and check
STM32 - switch of relay control lamp
Meituan dynamic thread pool practice ideas, open source
Qtablewidget lazy load remaining memory, no card!