写在前面思路分析结构体数组封装边元数据巧妙,map映射较麻烦其中,hash映射顶点通过下标直接获取顶点颜色枚举
原创
2022-08-23 15:47:57
21阅读
算法:深搜 代码一: 1 #include<iostream> 2 using namespace std; 3 int bb[26]={0},s,r,sum=1,s1=1; 4 char aa[25][25]; 5 int dir[4][2]={-1,0,1,0,0,-1,0,1}; 6 void
转载
2019-03-31 12:41:00
96阅读
2评论
1 LETTERS 2 Time Limit: 1000MS Memory Limit: 10000K 3 Total Submissions: 9298 Accepted: 4174 4 Description 5 6 A single-player game is played on a rectangular board divided in R ...
转载
2019-03-08 16:36:00
59阅读
2评论
1 class Solution:
2 def isLeap(self,year):
3 if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
4 return True
5 return False
6
7 def dayOfYea
转载
2019-09-10 16:13:00
48阅读
#include<iostream> //dfsusing namespace std;bool visited[26];char board[100][100];int r,s,n;bool vis(int x,int y){ if(x<1||x>r||y<1||y>s) return true; return visited[board[x][y]-'A'];}void dfs(int x,int y,int num){ if(vis(x-1,y)&&vis(x+1,y)&&vis(x,y-1)&&
转载
2011-07-22 19:59:00
59阅读
2评论
深搜简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 25int n, m;char map[maxn][maxn];bool vis[30];int ans;int dir[4][2] ={{ 0, 1 },{ 1, 0 },{ -1, 0 },{ 0, -1 } };bool ok(int x, int y){ if (x < 0 || y < 0
转载
2011-08-29 19:23:00
49阅读
2评论
题目题意:给定图的边信息,建图输出是
原创
2023-06-27 10:22:05
102阅读
题目描述 Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链。在项链上有N颗能量珠。能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数。并且,对于相邻的两颗珠子,前一颗珠子的尾标记一定等于后一颗珠子的头标记。因为只有这样,通过吸盘(吸盘是Mars人吸收能量的一
转载
2016-07-07 21:34:00
80阅读
2评论
传送门 1154 能量项链 2006年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 传送门 1154 能量项链 2006年NOIP全国联赛提高组 传送门 1154 能量项链 2006年NOIP全国联赛提高组 时间限制: 1 s 空间限制:
转载
2017-06-25 11:21:00
52阅读
2评论
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<vector>#inclu...
原创
2022-07-14 10:17:49
14阅读
区间DP大暴力吧?GG. dp[ i ] 为字符至 i 的最少数量。 如果[Left , Right]是回文串, dp[Right] = min(dp[ Right ] , dp[Left-1] + 1); #includeusing namespace std;const int N=5e...
转载
2017-03-28 19:37:00
118阅读
PAT 1154 C++版1.题意给出一个无向图的顶点和边信息,然后紧接着给出若干个查询样例。现在需要让我们判断,给出的查询样例是否满足 k-coloring。所谓的 k-coloring 指的是:A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertic...
原创
2022-01-26 09:58:47
57阅读
DescriptionGiven a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.Example 1:Input: date = "2019-01-09"
原创
2022-08-11 17:25:17
118阅读
1154Vertex Coloring(25 point(s))Aproper vertex coloringis a labeling of the graph's vert
原创
2022-09-15 10:53:28
50阅读
://www.51nod.com/onlineJudge/questionCode.html#!problemId=1154 1154 回文串划分 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 收藏 关注 有一个字符串S,求S最少可以被划分为
转载
2017-08-19 16:45:00
61阅读
2评论
我预处理$1e7log(1e7)$的因数被T掉了,就不敢往这个复杂度想了……无奈去看AC代码 结果怎么暴举gcd剪一剪小枝就接近3s卡过去了!vector有锅(确信
原创
2021-10-19 16:12:47
176阅读
染色法判断是否为$k$染色图,需要一个$vis$数组防止走环路。 const int N=10010; vector<int> g[N]; bool vis[N]; int color[N]; int n,m,q; bool dfs(int u) { vis[u]=true; for(int i=0
转载
2021-03-11 16:56:00
44阅读
素数筛模板AC代码:#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <algorithm>using namespace std;const int maxn=1e6+5;int a[maxn];void prime() { m
原创
2023-02-09 00:37:12
53阅读
PAT 1154 C++版1.题意给出一个无向图的顶点和边信息,然后紧接着给出若干个查询样例。现在需要让我们判断,给出的查询样例是否满足 k-coloring。所谓的 k-coloring 指的是:A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertic...
原创
2021-07-08 11:34:26
106阅读
ACdreamOJ 1154 Lowbit Sum (数位dp)ACM题目地址:p
转载
2015-09-26 18:38:00
35阅读
2评论