随笔分类 - 算法基础—模拟
摘要:不算很难的大模拟,考试的时候没做血亏。。不知道代码哪里有问题一直是90分,希望有大佬指出代码哪里有问题QAQ 首先s = -1的情况很容易,维护一个变量mode表示当前模式,直接根据题意模拟即可。关键在于校验码。仔细观察这实际上就是一个多项式除法,用去除得到的余式加个负号
阅读全文
摘要:不知道为啥是90分,而且是错误不是超时...正在忙着写web,等有时间再改吧 大体思路就是用队列去模拟(一开始写了个优先队列乱排序喜提70,改成普通队列就90了),node存储时间和节点以及当前节点的区块链。为什么要存当前节点的区块链?看看第二个样例的前两个询问就明白了,如果不这么存的话,2号节点就
阅读全文
摘要:挺nt的一个题,除了嗯模拟没想到更好的办法...大概就是每次遍历一遍所有的进程的当前通信,如果 可以收发则直接收发,然后更新当前通信;如果所有进程都不能收发则死锁。细节见代码。 #include <bits/stdc++.h> using namespace std; int t, n; struc
阅读全文
摘要:水题T*T class Solution { public: int a[25][25], dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; vector<vector<int>> generateMatrix(int n) { int x = 1, y
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/9984/H 来源:牛客网 题目描述 众所周知,吴楚月在数据结构课的大作业环节选择了表达式求值。 他觉得实现一个线性的表达式求值太无聊了,于是他把问题丢到了一棵树上。 形式化地讲,这棵树有 n 个节点,1 号点为根,每个节
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/9925/M 来源:牛客网 题目描述 Your git project (you don't need to be familiar with git to solve this problem) has some fil
阅读全文
摘要:主要是中缀转后缀+构造真值表进行判断,借助map来进行映射。 #include <iostream> #include <stack> #include <map> #include <vector> using namespace std; int n/*变元个数*/; map<char, int
阅读全文
摘要:Problem Description Little Rabbit is interested in radix. In a positional numeral system, the radix is the number of unique digits, including the digi
阅读全文
摘要:You are given a complete directed graph KnKn with nn vertices: each pair of vertices u≠vu≠v in KnKn have both directed edges (u,v)(u,v) and (v,u)(v,u)
阅读全文
摘要:The King of Berland Polycarp LXXXIV has nn daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princ
阅读全文
摘要:题目描述 鲁宾逊先生有一只宠物猴,名叫多多。这天,他们两个正沿着乡间小路散步,突然发现路边的告示牌上贴着一张小小的纸条:“欢迎免费品尝我种的花生!――熊字”。 鲁宾逊先生和多多都很开心,因为花生正是他们的最爱。在告示牌背后,路边真的有一块花生田,花生植株整齐地排列成矩形网格(如图111)。有经验的多
阅读全文
摘要:Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it. Gildong tries
阅读全文
摘要:Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where
阅读全文
摘要:There are nn monsters standing in a row numbered from 11 to nn . The ii -th monster has hihi health points (hp). You have your attack power equal to a
阅读全文