跳至内容
璟雯院
珺璟如晔,雯华若锦
用户工具
登录
站点工具
搜索
工具
显示页面
修订记录
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您在这里:
start
»
icpc
»
problems
»
luogup2952
icpc:problems:luogup2952
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
====== Cow Line ====== ===== 想法 ===== 用两个队列模拟双端队列。 ===== 代码实现 ===== <code c++> #include <cstdio> const int N = 100010; int line1[N], line2[N]; int head1 = 1, last1 = 0, head2 = 1, last2 = 0, cnt; int main() { int s, temp; char mod, turn; scanf("%d", &s); for (int i = 1; i <= s; i++) { scanf("\n%c %c", &mod, &turn); if (mod == 'A') { ++cnt; if (turn == 'L') line1[++last1] = cnt; else line2[++last2] = cnt; } else { scanf("%d", &temp); if (turn == 'R') { if (temp > (last2 - head2 + 1)) { temp -= (last2 - head2 + 1); last2 = head2 - 1; head1 += temp; } else last2 -= temp; } else { if (temp > (last1 - head1 + 1)) { temp -= (last1 - head1 + 1); last1 = head1 - 1; head2 += temp; } else last1 -= temp; } } } for (int i = last1; i >= head1; i--) printf("%d\n", line1[i]); for (int i = head2; i <= last2; i++) printf("%d\n", line2[i]); return 0; } </code>
/app/www/public/data/pages/icpc/problems/luogup2952.txt
· 最后更改: 2024/03/27 02:36 由
温婕莺
页面工具
显示页面
修订记录
反向链接
回到顶部