当前位置:网站首页>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;
}
边栏推荐
- 什么是调。调的故事
- SSL flood attack of DDoS attack
- Virtual list
- [QT] encapsulation of custom controls
- Steps to obtain SSL certificate private key private key file
- STM32 - GPIO input / output mode
- C#应用程序界面开发基础——窗体控制(1)——Form窗体
- tail -f 、tail -F、tailf的区别
- Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
- C#应用程序界面开发基础——窗体控制(2)——MDI窗体
猜你喜欢

Scheme and practice of cold and hot separation of massive data

Give you an array numbers that may have duplicate element values. It was originally an array arranged in ascending order, and it was rotated once according to the above situation. Please return the sm

C application interface development foundation - form control (3) - file control
![[shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)](/img/5e/1d451a820eadbd05112b41bd0bc7d6.gif)
[shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)

一比特苦逼程序員的找工作經曆

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

Introduction to flask tutorial
![[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core](/img/fb/c371ffaa9614c6f2fd581ba89eb2ab.png)
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core

Arduino dy-sv17f automatic voice broadcast

How is the mask effect achieved in the LPL ban/pick selection stage?
随机推荐
Why can't the start method be called repeatedly? But the run method can?
[interview question] 1369 when can't I use arrow function?
Thinkphp+redis realizes simple lottery
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
[data mining] task 1: distance calculation
网络安全-木马
Mathematical knowledge: divisible number inclusion exclusion principle
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
Cloud native topic sorting (to be updated)
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
[data mining] task 5: k-means/dbscan clustering: double square
d. LDC build shared library
【数据挖掘】任务1:距离计算
STM32 - GPIO input / output mode
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
The difference between tail -f, tail -f and tail
Test shift right: Elk practice of online quality monitoring
网络安全-中间人攻击
数学知识:Nim游戏—博弈论