当前位置:网站首页>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;
}
边栏推荐
- [FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
- C application interface development foundation - form control (4) - selection control
- [QT] encapsulation of custom controls
- C application interface development foundation - form control (3) - file control
- 2022-02-15 reading the meta module inspiration of the influxdb cluster
- 给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。【剑指Offer】
- Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
- Meituan dynamic thread pool practice ideas, open source
- Related concepts of GDB in embedded system
- 测试右移:线上质量监控 ELK 实战
猜你喜欢
简易分析fgui依赖关系工具
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
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
Installation and use of serial port packet capturing / cutting tool
STM32 - switch of relay control lamp
Why can't the start method be called repeatedly? But the run method can?
LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7
Expérience de recherche d'emploi d'un programmeur difficile
[技术发展-23]:DSP在未来融合网络中的应用
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
随机推荐
C application interface development foundation - form control (4) - selection control
网络安全-木马
数学知识:能被整除的数—容斥原理
数学知识:台阶-Nim游戏—博弈论
High resolution network (Part 1): Principle Analysis
tail -f 、tail -F、tailf的区别
Work experience of a hard pressed programmer
C language course information management system
How is the mask effect achieved in the LPL ban/pick selection stage?
Meituan dynamic thread pool practice ideas, open source
Test shift right: Elk practice of online quality monitoring
[interview question] 1369 when can't I use arrow function?
Take you ten days to easily complete the go micro service series (II)
Mathematical knowledge: step Nim game game game theory
电信客户流失预测挑战赛
【面试题】1369- 什么时候不能使用箭头函数?
网络安全-DNS欺骗与钓鱼网站
网络安全-破解系统密码
[data mining] task 6: DBSCAN clustering
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)