- 2024-12-16Moo University - Financial Aid POJ - 2010
//MooUniversity-FinancialAidPOJ-2010.cpp:此文件包含"main"函数。程序执行将在此处开始并结束。///*https://vjudge.net/problem/POJ-2010#author=GPT_zh贝西注意到,尽管人类有许多大学可供就读,但奶牛却没有。为了解决这个问题,她和她的同伴们成立了一所新的大
- 2024-12-06题解:[USACO07DEC] Sightseeing Cows G
洛谷P2868题目大意有个$n$个点,$m$条边的有向图,点有点权,边有边权。现在要找出一个环,使得点权和与边权和的比值最大。思路既然说要使得点权和与边权和的比值最大,那么就会想到$01$分数规划。二分答案就不用说了,重点是这个$check$函数。$01$分数规划的板子中要检查的是
- 2024-11-23[USACO03Open] Lost Cows
题目Description有 NN 头奶牛,已知它们的编号为 1∼N1∼N 且各不相同,但不知道每头奶牛的具体编号。现在这 NN 头奶牛站成一列,已知第 ii 头奶牛前面有 aiai 头牛编号小于它,求每头奶牛的编号。Input第 11 行,输入一个整数 NN第 2...N2...N 行,每行输入一个
- 2024-12-0811月上笔记
AI⼯具库合集Al⽂本⼯具1.1主流语⾔⼤模型ChatGPT:OpenAI旗下的⼈⼯智能聊天机器⼈程序ChatGPT(需要魔法、免费+付费)⽂⼼⼀⾔:百度公司开发的聊天机器⼈⽂⼼⼀⾔(⽆需魔法)智谱清⾔:由智谱AI开发的⼤模型智谱清⾔通义千问:阿⾥巴巴推出的⼤语⾔模型通义千问百川⼤模型
- 2024-09-10题解:[USACO07DEC] Sightseeing Cows G
洛谷P2868题目大意有个nnn个点,mmm条边的有向图,点有点权,边有边
- 2024-08-20题解:P9944 [USACO21FEB] Comfortable Cows B
思路由于每次输入\(x\)和\(y\)只改变其上下左右的值,所以每次只要更新其相邻的值即可。当某个位置相邻的奶牛数达到\(3\)时,舒适度加一。当某个位置相邻的奶牛数达到\(4\)时,舒适度减一。注意:每增加一头奶牛以后,如果该位置相邻正好有三头奶牛,则舒适度也要加一。ACcod
- 2024-07-26P3131 [USACO16JAN] Subsequences Summing to Sevens S
传送锚点:[USACO16JAN]SubsequencesSummingtoSevensS-洛谷题目描述FarmerJohn's\(N\)cowsarestandinginarow,astheyhaveatendencytodofromtimetotime.EachcowislabeledwithadistinctintegerIDnumbersoFJcantellthemapart.FJwould
- 2024-07-23面向前方
[USACO07MAR]FaceTheRightWayG题目描述FarmerJohnhasarrangedhisN(1≤N≤5,000)cowsinarowandmanyofthemarefacingforward,likegoodcows.Someofthemarefacingbackward,though,andheneedsthemalltofaceforwardtomakehislifeper
- 2024-07-12Cows in a Skyscraper G
dfs版本#include<algorithm>#include<iostream>usingnamespacestd;constintN=2e1;intcat[N],cab[N];intn,w;intans;boolcmp(inta,intb){returna>b;}voiddfs(intnow,intcnt){if(cnt>=ans){re
- 2024-07-08P7411 [USACO21FEB] Comfortable Cows S (搜索)
P7411[USACO21FEB]ComfortableCowsS搜索容易知道任意时刻的不合法的位置,并且决策只有将空着的位置补起来。每次加入一个点,判断其自身、上下左右是否变得不合法,往下递归即可。复杂度分析,每个点只会不合法一次(修改后就变得合法),所以只会遍历一次,复杂度是\(O(n^2)\)。#inclu
- 2024-06-22P3056 [USACO12NOV] Clumsy Cows S
[USACO12NOV]ClumsyCowsS题目描述Bessiethecowistryingtotypeabalancedstringofparenthesesintohernewlaptop,butsheissufficientlyclumsy(duetoherlargehooves)thatshekeepsmis-typingcharacters.Pleasehelpherbycomputingthemi
- 2024-04-24P3667 [USACO17OPEN] Bovine Genomics G (set容器)
[USACO17OPEN]BovineGenomicsG题目描述FarmerJohnowns\(N\)cowswithspotsand\(N\)cowswithoutspots.Havingjustcompletedacourseinbovinegenetics,heisconvincedthatthespotsonhiscowsarecausedbymutationsinthebovinegenome.Atgr
- 2024-04-05P3052 [USACO12MAR] Cows in a Skyscraper G
原题链接题解模拟,遍历n个物品,一开始一个箱子不给,遍历到某个物品时,先把所有已经给了的箱子放进去试试,再创一个新箱子放进去试试code#include<bits/stdc++.h>usingnamespacestd;intn,w;intcnt,ans;intchongdie=0;intbox[20],c[20];voidmoni(intnow,intcnt)//now
- 2024-03-04P3047 [USACO12FEB] Nearby Cows G
原题链接题解核心技巧:两次搜索第一次搜索:搜索出\(f[now][i]\)以\(now\)为根节点的子树且距离根节点恰好为\(i\)的节点的个数搜索完了之后,把范围\(k\)以内的累加第二次搜索:由于整棵树的根节点的\(f\)等于整棵树里距离不大于\(k\)的节点个数,即已经符合题目要求
- 2024-02-26P7154 Sleeping Cows 题解
传送门题意:给定两个数组\(a_i,b_i\),若\(a_i\leb_j\),则他俩可配对。求极大匹配的方案数。(极大不是最大,最大一定是极大)先考虑最大匹配方案数怎么求。把\(a\)和\(b\)从小到大排序。则每个\(a_i\)能匹配的\(b\)都是一段后缀,且随着\(i\)增大,这个后缀越来越小。于是从
- 2023-12-30[USACO07DEC] Sightseeing Cows G
[USACO07DEC]SightseeingCowsG题目描述FarmerJohnhasdecidedtorewardhiscowsfortheirhardworkbytakingthemonatourofthebigcity!Thecowsmustdecidehowbesttospendtheirfreetime.Fortunately,theyhaveadetailedcitymapshowingthe$L
- 2023-11-09P9194 [USACO23OPEN] Triples of Cows P 题解
Description给定一棵初始有\(n\)个点的树。在第\(i\)天,这棵树的第\(i\)个点会被删除,所有与点\(i\)直接相连的点之间都会两两连上一条边。你需要在每次删点发生前,求出满足\((a,b)\)之间有边,\((b,c)\)之间有边且\(a\not=c\)的有序三元组\((a,b,c)\)对数。\(n\leq2
- 2023-09-12POJ 2186-Popular Cows ---强连通分量
本题让求有多少点 是图中所有点都可到达改点的定理:在一个有向图中,如果有一个节点的出度为0,并且仅有一个这样的点,则该图中所有的点都可到达该点先求出图的强连通分量,然后将每个强连通分量化为一个层次,求是否存在一个强连通分量,该分量的出度为一,并且仅有一个这样的分量,则该连通分量
- 2023-08-12Electric Fence
描述Inthisproblem,"latticepoints"intheplanearepointswithintegercoordinates.Inordertocontainhiscows,FarmerJohnconstructsatriangularelectricfencebystringinga"hot"wirefromtheorigin(0,0)toalatticepoint
- 2023-07-06P3047 [USACO12FEB] Nearby Cows G
#include<iostream>#include<vector>usingnamespacestd;constintN=100010,M=30;intn,m;intw[N];vector<int>g[N];intf[N][M],ans[N][M];voidDP1(intu,intfa){ for(inti=0;i<=m;i++)f[u][i]=w[u]; for(intx:g
- 2023-06-13[USACO06FEB]Treats for the Cows G/S
[USACO06FEB]TreatsfortheCowsG/S题目描述FJhaspurchasedN(1<=N<=2000)yummytreatsforthecowswhogetmoneyforgivingvastamountsofmilk.FJsellsonetreatperdayandwantstomaximizethemoneyhereceivesoveragivenperiodtime.Th
- 2023-06-12Codeforces Round #225 (Div. 2)-C. Milking cows
原题链接C.Milkingcowstimelimitpertestmemorylimitpertestinputoutputn cowssittinginarow,numberedfrom 1 to nIahubcandecidetheorderinwhichhemilksthecows.Buthemustmilkeachcowex
- 2023-06-12POJ 3264 Balanced Lineup
思路:线段树求最大值减最小值,每个结点分别维护最大值和最小值即可。#include<cstdio>#include<queue>#include<cstring>#include<iostream>#include<cstdlib>#include<algorithm>#include<vector>#include<map>#include<string>#in