CodeForces Round 223 Div 2 C Sereja and Prefixes
2014-01-13 02:05
381 查看
乱搞题..
题目链接 http://codeforces.com/problemset/problem/380/A
一个人要做个数字序列,有两种操作,1 是 向后面加个数字 2 是向后面加上从 1 到 l 的复制 C 次的序列
最后有 m 个询问
记录下每个操作所诞生的序列的开始位置
记录下每个操作的信息,放在 node 里面
遇到 类型 1 的节点 直接返回值
遇到 类型 2 的节点就继续查找
题目链接 http://codeforces.com/problemset/problem/380/A
一个人要做个数字序列,有两种操作,1 是 向后面加个数字 2 是向后面加上从 1 到 l 的复制 C 次的序列
最后有 m 个询问
记录下每个操作所诞生的序列的开始位置
记录下每个操作的信息,放在 node 里面
遇到 类型 1 的节点 直接返回值
遇到 类型 2 的节点就继续查找
#include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> #include<deque> #include<set> #include<vector> using namespace std; #define LL long long #define fst first #define sec second #define P pair<LL , LL> #define MAX 200000 int na; int np; struct nod { LL l,r; LL t; LL time; LL v; LL type; }node[MAX]; LL start[MAX]; int main() { int n; cin >> n; LL len = 0; for(int i = 0; i < n; i++) { int t; cin >> t; if(t == 1) { int num; cin >> num; start[i] = len + 1; len ++ ; node[i].l = len; node[i].r = len; node[i].v = num; node[i].type = 1; } else { int to,ti; cin >> to >> ti; start[i] = len + 1; node[i].l = len + 1; len += to * ti; node[i].r = len; node[i].t = to; node[i].time = ti; node[i].type = 2; } } start = 0x3f3f3f3f; int m; cin >> m; for(int i = 0;i < m; i++) { LL q; cin >> q; LL j; while(1) { j = upper_bound(start, start + n, q) - start - 1; if(node[j].type == 2) { q = (q - node[j].l + 1) % (node[j].t); if( q == 0 ) q = node[j].t; continue; } else { break; } } cout << node[j].v << " "; } return 0; }
相关文章推荐
- Codeforces Round #243 (Div. 2)——Sereja and Table
- Codeforces Round #235 (Div. 2)B. Sereja and Contests
- Codeforces Round #215 (Div. 1) C. Sereja and the Arrangement of Numbers(欧拉图)
- CodeForces Round 213 Div 2 E Sereja and Brackets 线段树
- Codeforces Round #215 (Div. 2) C. Sereja and Algorithm
- Codeforces Round #215_div2_C. Sereja and Algorithm
- Codeforces Round #243 (Div. 1)——Sereja and Two Sequences
- 【Codeforces Round 262 (Div 2)D】【构造】Little Victor and Set 集合最多取k数使得异或值尽可能小
- Codeforces Round #264 (div2)B. Caisa and Pylons
- Codeforces Round #442 (Div. 2) D. Olya and Energy Drinks (bfs)
- Codeforces Round #425 (Div. 2) A. Sasha and Sticks
- Codeforces Round #330 (Div. 2) A. Vitaly and Night
- 【Codeforces Round 263 (Div 2)D】【树形DP】Appleman and Tree 树上割k个黑点为k块的方案数
- Codeforces Round #277.5 (Div. 2)-C. Given Length and Sum of Digits...
- 【解题报告】ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined)
- Codeforces Round #291 (Div. 2)C.Watto and Mechanism——字典树+dfs
- 【Codeforces Round 354 (Div 2)A】【水题 贪心】Nicholas and Permutation 恰好交换一次的pos[n]-pos[1]
- 【Codeforces Round 370 (Div 2) B】【简单贪心】Memory and Trident
- Codeforces Round #420 (Div. 2) E. Okabe and El Psy Kongroo DP+矩阵快速幂加速
- Codeforces Round #234 (Div. 2) B. Inna and New Matrix of Candies