当前位置:网站首页>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;
}
边栏推荐
- 网络安全-木马
- Tâche 6: regroupement DBSCAN
- [data mining] task 4:20newsgroups clustering
- [Cao gongzatan] after working in goose factory for a year in 2021, some of my insights
- Main features of transport layer TCP and TCP connection
- 测试右移:线上质量监控 ELK 实战
- Wordinsert formula /endnote
- C application interface development foundation - form control (2) - MDI form
- Do not log in or log in to solve the problem that the Oracle database account is locked.
- Look at how clothing enterprises take advantage of the epidemic
猜你喜欢
High resolution network (Part 1): Principle Analysis
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
[shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)
Everything文件搜索工具
STM32 - introduction of external interrupts exti and NVIC
NCTF 2018 part Title WP (1)
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
C application interface development foundation - form control (1) - form form
网络安全-漏洞与木马
音程的知识的总结
随机推荐
STM32 - introduction of external interrupts exti and NVIC
What operations need attention in the spot gold investment market?
一位苦逼程序员的找工作经历
传输层 TCP主要特点和TCP连接
串口抓包/截断工具的安装及使用详解
Is there anything in common between spot gold and spot silver
网络安全-扫描
Summary of interval knowledge
Steps to obtain SSL certificate private key private key file
JUC thread scheduling
uniapp组件-uni-notice-bar通告栏
Virtual list
QTableWidget懒加载剩内存,不卡!
Druid database connection pool
【面试题】1369- 什么时候不能使用箭头函数?
【数据挖掘】任务4:20Newsgroups聚类
[shutter] animation animation (the core class of shutter animation | animation | curvedanimation | animationcontroller | tween)
Force buckle 204 Count prime
网络安全-钓鱼
Test shift right: Elk practice of online quality monitoring