当前位置:网站首页>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;
}
边栏推荐
- CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
- 一比特苦逼程序員的找工作經曆
- Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
- Learn the five skills you need to master in cloud computing application development
- MySQL - database query - basic query
- VIM 9.0 is officially released! The execution speed of the new script can be increased by up to 100 times
- Take you ten days to easily complete the go micro service series (I)
- Main features of transport layer TCP and TCP connection
- 网络安全-浅谈安全威胁
- NCTF 2018 part Title WP (1)
猜你喜欢

CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr

How is the mask effect achieved in the LPL ban/pick selection stage?

Soft exam information system project manager_ Real topic over the years_ Wrong question set in the second half of 2019_ Morning comprehensive knowledge question - Senior Information System Project Man

NCTF 2018 part Title WP (1)

【数据挖掘】任务2:医学数据库MIMIC-III数据处理

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

Learn the five skills you need to master in cloud computing application development

STM32 - Application of external interrupt induction lamp

力扣 204. 计数质数
![[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#应用程序界面开发基础——窗体控制(2)——MDI窗体
[shutter] animation animation (the core class of shutter animation | animation | curvedanimation | animationcontroller | tween)
Learn the five skills you need to master in cloud computing application development
LDC Build Shared Library
Why can't the start method be called repeatedly? But the run method can?
Mathematical knowledge: step Nim game game game theory
Using tensorboard to visualize the model, data and training process
网络安全-openvas
7-25 read numbers (loop switch)
Tp6 fast installation uses mongodb to add, delete, modify and check
The meaning of wildcard, patsubst and notdir in makefile
云原生题目整理(待更新)
mysql
High-Resolution Network (篇一):原理刨析
网络安全-中间人攻击
Sweet talk generator, regular greeting email machine... Open source programmers pay too much for this Valentine's day
[shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)
网络安全-漏洞与木马
网络安全-木马
Look at how clothing enterprises take advantage of the epidemic