1.5
This commit is contained in:
1 parent
67f3e16535
commit
99ed42d095
8 files changed
+294
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package com.hong.www;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class A1024 {
|
||||
public int videoStitching(int[][] clips, int time) {
|
||||
Arrays.sort(clips, (a, b) -> b[1] - a[1]);
|
||||
int now = time;
|
||||
int next = time;
|
||||
int finalCount = 0;
|
||||
for (int[] x : clips) {
|
||||
if (x[1] >= now) {
|
||||
if (x[0] < next) {
|
||||
next = x[0];
|
||||
}
|
||||
if(next == 0) {
|
||||
return finalCount + 1;
|
||||
}
|
||||
} else if (next <= x[1]) {
|
||||
finalCount++;
|
||||
now = next;
|
||||
if (next >= x[0]) {
|
||||
next = x[0];
|
||||
}
|
||||
if(next == 0) {
|
||||
return finalCount + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
A1024 a1024 = new A1024();
|
||||
int[][] clips = { { 0, 1 }, { 6, 8 }, { 0, 2 }, { 5, 6 }, { 0, 4 }, { 0, 3 }, { 6, 7 }, { 1, 3 }, { 4, 7 },
|
||||
{ 1, 4 }, { 2, 5 }, { 2, 6 }, { 3, 4 }, { 4, 5 }, { 5, 7 }, { 6, 9 } };
|
||||
System.out.println(a1024.videoStitching(clips, 9));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.hong.www;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class A210 {
|
||||
public int[] findOrder(int numCourses, int[][] prerequisites) {
|
||||
if(prerequisites.length==0){
|
||||
int[] temp = new int[numCourses];
|
||||
for(int i=0;i<numCourses;i++){
|
||||
temp[i]=i;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
Arrays.sort(prerequisites,(a,b)->a[1]-b[1]);
|
||||
HashSet<Integer> temp =new HashSet<>();
|
||||
int[] fina =new int[numCourses];
|
||||
fina[0]=prerequisites[0][1];
|
||||
int n=1;
|
||||
temp.add(prerequisites[0][1]);
|
||||
for(int[] x:prerequisites){
|
||||
if(temp.contains(x[1])){
|
||||
if(temp.contains(x[0])){
|
||||
return new int[]{};
|
||||
}else if(!temp.contains(x[0])){
|
||||
temp.add(x[0]);
|
||||
fina[n]=x[0];
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(temp.size()==numCourses){
|
||||
return fina;
|
||||
}
|
||||
return new int[]{};
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
A210 a210 = new A210();
|
||||
int[][] prerequisites = {{1,0},{2,0},{3,1},{3,2}};
|
||||
int[] order = a210.findOrder(4, prerequisites);
|
||||
System.out.println(Arrays.toString(order));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.hong.www;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class A51 {
|
||||
public List<List<String>> solveNQueens(int n) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.hong.www;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class A743 {
|
||||
public int networkDelayTime(int[][] times, int n, int k) {
|
||||
PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> a[1] - b[1]);
|
||||
HashMap<Integer,ArrayList<int[]>> xxx=new HashMap<>();
|
||||
int[] dist=new int[n+1];
|
||||
Arrays.fill(dist, Integer.MAX_VALUE);
|
||||
dist[0]=0;
|
||||
for(int[] x:times){
|
||||
if(xxx.containsKey(x[0])){
|
||||
xxx.get(x[0]).add(new int[]{x[1],x[2]});
|
||||
}else{
|
||||
ArrayList<int[]> temp=new ArrayList<>();
|
||||
temp.add(new int[]{x[1],x[2]});
|
||||
xxx.put(x[0],temp);
|
||||
}
|
||||
}
|
||||
int[] temp=new int[]{k,0};
|
||||
dist[k]=0;
|
||||
pq.offer(temp);
|
||||
while (!pq.isEmpty()) {
|
||||
int[] temp0=pq.poll();
|
||||
if(temp0[1]>dist[temp0[0]]){
|
||||
continue;
|
||||
}
|
||||
if(xxx.containsKey(temp0[0])){
|
||||
for(int[] temp1:xxx.get(temp0[0])){
|
||||
if(dist[temp0[0]]+temp1[1]<dist[temp1[0]]){
|
||||
dist[temp1[0]]=dist[temp0[0]]+temp1[1];
|
||||
pq.offer(new int[]{temp1[0],dist[temp1[0]]});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int max=0;
|
||||
for(int i=1;i<dist.length;i++){
|
||||
if(dist[i]==Integer.MAX_VALUE) return -1;
|
||||
max=Math.max(max,dist[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.hong.www;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class A847 {
|
||||
public int shortestPathLength(int[][] graph) {
|
||||
int n=graph.length;
|
||||
boolean[][] visited=new boolean[n][1<<n];
|
||||
LinkedList<int[]> queue=new LinkedList<>();
|
||||
for(int i=0;i<n;i++){
|
||||
queue.add(new int[]{i,1<<i,0});
|
||||
visited[i][1<<i]=true;
|
||||
}
|
||||
int target=(1<<n)-1;
|
||||
while (!queue.isEmpty()) {
|
||||
int[] now=queue.get(0);
|
||||
queue.remove(0);
|
||||
if(now[1]==target) {
|
||||
return now[2];
|
||||
}
|
||||
for (int y:graph[now[0]]) {
|
||||
int nextMask=now[1]|(1<<y);
|
||||
if (!visited[y][nextMask]) {
|
||||
visited[y][nextMask]=true;
|
||||
queue.add(new int[]{y,nextMask,now[2]+1});
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.hong.www;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LCP16 {
|
||||
/*
|
||||
* public int bfs(int i, HashMap<Integer, ArrayList<Integer>> temp, int from,
|
||||
* int then) {
|
||||
* int x = 0;
|
||||
* int x
|
||||
* then = 1;
|
||||
* if (temp.get(i) != null) {
|
||||
* for (int xx : temp.get(i)) {
|
||||
* if (then == 0 && xx != i) {
|
||||
* x += bfs(i, temp, from, then);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* return x;
|
||||
* }
|
||||
*/
|
||||
|
||||
public int maxWeight(int[][] edges, int[] value) {
|
||||
HashMap<Integer, ArrayList<Integer>> temp = new HashMap<>();
|
||||
int ans = 0;
|
||||
for (int[] x : edges) {
|
||||
if (temp.containsKey(x[0])) {
|
||||
temp.get(x[0]).add(x[1]);
|
||||
} else {
|
||||
ArrayList<Integer> tem = new ArrayList<>();
|
||||
tem.add(x[1]);
|
||||
temp.put(x[0], tem);
|
||||
}
|
||||
if (temp.containsKey(x[1])) {
|
||||
temp.get(x[1]).add(x[0]);
|
||||
} else {
|
||||
ArrayList<Integer> tem = new ArrayList<>();
|
||||
tem.add(x[0]);
|
||||
temp.put(x[1], tem);
|
||||
}
|
||||
}
|
||||
for (int A=0; A<value.length; A++) {
|
||||
ArrayList<int[]> xxxx = new ArrayList<>();
|
||||
for (int x : temp.get(A)) {
|
||||
if (x != A) {
|
||||
for (int xxx : temp.get(x)) {
|
||||
if (xxx != x && xxx != A) {
|
||||
for(int s: temp.get(xxx)){
|
||||
if(s==A&&xxxx.contains(new int[] { xxx, x })==false){
|
||||
xxxx.add(new int[] { x, xxx });
|
||||
}
|
||||
}
|
||||
//xxxx.add(new int[] { x, xxx });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < xxxx.size(); i++) {
|
||||
for (int j = i; j < xxxx.size(); j++) {
|
||||
// 1. 把 A 加进去
|
||||
Set<Integer> combine = new HashSet<>();
|
||||
combine.add(A);
|
||||
|
||||
// 2. 把三角形 i 加进去
|
||||
combine.add(xxxx.get(i)[0]);
|
||||
combine.add(xxxx.get(i)[1]);
|
||||
|
||||
// 3. 把三角形 j 加进去(Set 会自动去重)
|
||||
combine.add(xxxx.get(j)[0]);
|
||||
combine.add(xxxx.get(j)[1]);
|
||||
|
||||
// 4. 累加当前方案的真实收益
|
||||
int total = 0;
|
||||
for (int v : combine) {
|
||||
total += value[v];
|
||||
}
|
||||
|
||||
// 5. 更新最大值
|
||||
ans = Math.max(ans, total);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
LCP16 solution = new LCP16();
|
||||
int[][] edges = { { 0,2 }, { 2,1 }};
|
||||
int[] value = { 1, 2, 5 };
|
||||
System.out.println(solution.maxWeight(edges, value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hong.www;
|
||||
|
||||
public class LCP25 {
|
||||
public int keyboard(int k, int n) {
|
||||
int[][] dp=new int[k+1][n+1];
|
||||
for(int i=0;i<=k;i++){
|
||||
dp[i][0]=0;
|
||||
}
|
||||
for(int j=0;j<=n;j++){
|
||||
dp[0][j]=0;
|
||||
}
|
||||
for(int i=1;i<=k;i++){
|
||||
for(int j=1;j<=n;j++){
|
||||
|
||||
}
|
||||
}
|
||||
return dp[k][n];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
首先是进入副本环节:
|
||||
应该是玩家匹配进入副本 首先匹配成功之后需要玩家在从进行确认 确保在线
|
||||
玩家有一个如果没有确认,那么就重新进入匹配队列再次进行匹配
|
||||
确认4个人前后信息无误
|
||||
不会卷入其他人或者是上次没有确认的人
|
||||
进入副本之后:
|
||||
如果玩家掉线 玩家头像是否显示掉线 玩家模型是否隐藏 玩家血量是否锁定 玩家技能冷却是重置还是进行保持
|
||||
boss转阶段:
|
||||
如果玩家在被打归零时候掉线是否需要复活 重连复活时候队友死亡如果只有一个复活次数是否只能复活一个(这种多个关键时刻卡一起的时候最阴了)
|
||||
如果玩家在上一个阶段掉线 在这个阶段是否正常同步
|
||||
玩家的状态是否都正常生效(比如移除上阶段的buff 这阶段的bossbuff是否正常生效等)
|
||||
如果玩家在转阶段动画播放时候加入是否进行限制
|
||||
结束阶段:
|
||||
如果玩家在此阶段连接,阶段是否正常刷新 场景是否正常更换
|
||||
玩家在点击获得奖励时候再掉线是否正常只触发一次(掉线前成功,或者是掉线时失败了 回来依然能够正常领取)(我的建议是点击领取奖励之后进行判断背包没满等异常条件之后将领取奖励和发放奖励作为后端的一个指令进行 不受客户端的时断时续的请求的干扰)
|
||||
玩家如果死亡掉线 在这里复活是否正常复活
|
||||
如果此次副本已经结束(其它玩家退出) 玩家再次重连(没领取奖励)是否为其保留场景还是自动分发 还是直接消除场景 这次不计入奖励(如果分发包括玩家背包满了等异常情况视设计看是否补偿到邮件)
|
||||
如果玩家已经领取了奖励 玩家再次重连是否回到正常位置(如副本门口)
|
||||
Reference in new issue
Block a user