上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 67 下一页
摘要: 暴力做法:\(O(n^2)\)。 const int N=1010; int a[N]; int l[N],r[N]; int n; int main() { cin>>n; for(int i=0;i<n;i++) cin>>a[i]; int res=0; for(int i=0;i<n;i++ 阅读全文
posted @ 2021-03-08 18:28 Dazzling! 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 注意'X'的处理。 string s; int main() { cin>>s; int res=0,w=1; for(int i=0;i<s.size()-1;i++) if(isdigit(s[i])) res+=(s[i]-'0')*w++; if((s[s.size()-1] == 'X' 阅读全文
posted @ 2021-03-07 23:56 Dazzling! 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 水~。 int cnt[10010]; int n; int main() { cin>>n; for(int i=0;i<n;i++) { int x; cin>>x; cnt[x]++; } int res=0; for(int i=0;i<10001;i++) if(cnt[res] < cn 阅读全文
posted @ 2021-03-07 23:41 Dazzling! 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 并查集水题~。 const int N=10010; int p[N]; int n,m,q; int find(int x) { if(x != p[x]) p[x]=find(p[x]); return p[x]; } int main() { cin>>m; for(int i=1;i<N;i 阅读全文
posted @ 2021-03-06 21:04 Dazzling! 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 注意括号序列的输出,首先叶子结点不需要括号,其次最外层也不需要括号。 const int N=25; PII tree[N]; string a[N]; int fa[N]; bool leaf[N]; int n; int root=1; void inorder(int u) { if(u == 阅读全文
posted @ 2021-03-06 20:51 Dazzling! 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 考察点:试除法求约数、方向数组。 类似题:756. 蛇形矩阵。 const int N=10010; int a[N]; int dx[]={0,1,0,-1},dy[]={1,0,-1,0}; int k,n,m; int cnt; bool check(int x,int y) { return 阅读全文
posted @ 2021-03-06 17:27 Dazzling! 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 注意图不一定连通!。 const int N=510; bool g[N][N]; int d[N]; bool vis[N]; int n,m; int cnt; void dfs(int u) { vis[u]=true; cnt++; for(int i=1;i<=n;i++) if(g[u] 阅读全文
posted @ 2021-03-06 15:08 Dazzling! 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 注意结果向下取整。 因为所有长度都要串在一起,每次都等于(旧的绳子长度+新的绳子长度)/2,所以越是早加入绳子长度中的段,越要对折的次数多,所以既然希望绳子长度是最长的,就必须让长的段对折次数尽可能的短。 将所有段从小到大排序,然后从头到尾从小到大分别将每一段依次加入结绳的绳子中,最后得到的结果才会 阅读全文
posted @ 2021-03-06 12:38 Dazzling! 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 水~。 const int N=1010; string a[N]; unordered_set<string> S; int n,step,idx; int main() { cin>>n>>step>>idx; for(int i=1;i<=n;i++) cin>>a[i]; for(int i 阅读全文
posted @ 2021-03-06 11:57 Dazzling! 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 参考柳神代码,考察$set$的自定义排序。 const int N=50010; struct Node { int item; int times; bool operator<(const Node &W) const { if(times != W.times) return times > 阅读全文
posted @ 2021-03-06 11:37 Dazzling! 阅读(54) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 67 下一页