当前位置:网站首页>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;
}
边栏推荐
- 网络安全-浅谈安全威胁
- 网络安全-中间人攻击
- 网络安全-木马
- C#应用程序界面开发基础——窗体控制(1)——Form窗体
- 英语常用词汇
- Why can't the start method be called repeatedly? But the run method can?
- Mathematical Knowledge: Steps - Nim Games - Game Theory
- word插入公式/endnote
- Do not log in or log in to solve the problem that the Oracle database account is locked.
- 网络安全-漏洞与木马
猜你喜欢
![[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)](/img/3c/93ef853784d4e7cef63f30be0b0bf2.jpg)
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)

Tâche 6: regroupement DBSCAN

Main features of transport layer TCP and TCP connection
![[data mining] task 3: decision tree classification](/img/9a/1cb2a8a90f16e7bfa9b48e516a966c.png)
[data mining] task 3: decision tree classification

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

Top ten regular spot trading platforms 2022

Qtablewidget lazy load remaining memory, no card!

网络安全-漏洞与木马

Summary of interval knowledge
![[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio](/img/32/fa1263d9a2e5f77b0434fce1912cb2.gif)
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
随机推荐
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
Types of map key and object key
Take you ten days to easily complete the go micro service series (I)
数学知识:台阶-Nim游戏—博弈论
[data mining] task 3: decision tree classification
NCTF 2018 part Title WP (1)
Androd gradle's substitution of its use module dependency
STM32 - switch of relay control lamp
Telecom Customer Churn Prediction challenge
STM32 - GPIO input / output mode
Qtablewidget lazy load remaining memory, no card!
网络安全-漏洞与木马
Mathematical Knowledge: Steps - Nim Games - Game Theory
QTableWidget懒加载剩内存,不卡!
The thread reuse problem of PageHelper using ThreadLocal, did you use it correctly?
LDC Build Shared Library
tail -f 、tail -F、tailf的区别
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
什么是调。调的故事