日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ue 抗锯齿 渲染序列失灵_最大的锯齿形序列

發布時間:2025/3/11 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ue 抗锯齿 渲染序列失灵_最大的锯齿形序列 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ue 抗鋸齒 渲染序列失靈

Problem statement:

問題陳述:

Given a square matrix of size n x n, find the sum of the Zigzag sequence with the largest sum. A zigzag sequence starts from the top and ends at the bottom. Two consecutive elements of sequence cannot belong to the same column.

給定大小為nxn的方陣, 找到Zigzag序列的總和最大 。 之字形序列從頂部開始,在底部結束。 序列的兩個連續元素不能屬于同一列。

Input:First line contains an integer N denoting the size of the matrix. Then in the next line are N*N space separated values of the matrix.Output:Print the required max sum.Constraints:1<=N<=1001<=M[][]<=1000

Example:

例:

Input:Input matrix3 8 24 8 56 9 7Output: 22Maximum Zigzag sequence is: 8->5->9Other sequences can be: 3->8->6 etc.Input:Input matrix3 2 110 8 5 6 6 4Output: 18In the above also, the maximum zigzag sequence will be:2->10->6

The second example clearly shows that the greedy solution wouldn't work. Let's say we opt for greedy technique and as a measure, what we do is to extract local maximum, i.e., to extract maximum out of this row and the go-ahead to the next row and find out maximum skipping the column where we found our last maximum.

第二個例子清楚地表明,貪婪的解決方案是行不通的。 假設我們選擇貪婪技術,并且作為一種度量,我們要做的是提取局部最大值,即從該行中提取最大值,然后繼續到下一行,并找出最大值,跳過找到我們的列最后的最大值。

So if we follow a similar approach, let's check what we can lead to.

因此,如果我們采用類似的方法,那么讓我們檢查一下會導致什么。

So, firstly, we will pick 3 out of the first row (0th row)

因此,首先,我們將從第一行( 0行)中選擇3

From the next row, we will pick 8 as we can't peek 10 due to out constraint.

在下一行中,我們將選擇8 ,因為由于出局限制我們無法窺視10 。

And from the next row, we will pick 6?(of 0th column)

然后從下一行中,選擇6 ( 0列)

So it sums up to 3+8+6 which is 17. But it's wrong we know output would be 18. So finding local best doesn't lead to global best. Hence, greedy will not work here.

因此,總和為3 + 8 + 6 ,即17 。 但是我們知道輸出為18是錯誤的。 因此,找到本地最佳并不能帶來全球最佳。 因此,貪婪在這里不起作用。

We need dynamic programing or recursion to solve.

我們需要動態編程或遞歸來解決。

Solution Approach:

解決方法:

So, let's see what can be a recursive solution. Then, we will check for overlapping sub-problems and will gradually optimize the recursion by memorization.

因此,讓我們看看什么是遞歸解決方案。 然后,我們將檢查重疊的子問題,并通過記憶逐步優化遞歸。

Let the recursive function be, recurZigzag(matrix, currow, curcolulm, n)

設遞歸函數為recurZigzag(matrix,cur row ,cur colulm ,n)

Function recurZigzag(matrix,currow,curcolulm):If (currow reaches n)Return 0;for i=0 to n except curcolumnReturn matrix[currow][curcolumn] + max(recurZigzag(matrix, currow + 1, i))End Function// In the main functionfor column=0 to n-1result=max?(result,recurZigzag(matrix,0,column)

So what we did?

那我們做了什么?

We are starting from each column on the top row.

我們從第一行的每一列開始。

Then we are recursively checking for the next row skipping the current column. So, this checks all combinations possible.

然后,我們遞歸地檢查跳過當前列的下一行。 因此,這將檢查所有可能的組合。

I would recommend to create the recursion tree for example 1 and check whether you can find overlapping sub-problems. There will be a lot of overlapping problems even for smaller inputs.

我建議為示例1創建遞歸樹,并檢查是否可以找到重疊的子問題。 即使對于較小的輸入,也會有很多重疊的問題。

So, we need to pass that overhead and we can solve that by memorization technique where we store the value of solved sub-problem in DP[][]

因此,我們需要傳遞該開銷,并且可以通過存儲將已解決子問題的值存儲在DP [] []中的記憶技術來解決該問題。

So, we first lookup in DP[][] whether it's already solved or not. If it's already solved then we will have some value for DP[i][j] (for subproblem, f(i,j)), Else DP[i][j] will contain the initialized value only.

因此,我們首先在DP [] []中查找它是否已解決。 如果已經解決,則DP [i] [j]會有一些值(對于子問題f(i,j) ),其他DP [i] [j]僅包含初始化值。

This is the trick here.

這是這里的把戲。

Below is the full CPP implementation for understanding memorization.

以下是用于理解記憶的完整CPP實施。

C++ Implementation:

C ++實現:

#include <bits/stdc++.h> using namespace std;int findmax(vector<int> arr, int in, int n, int* lastindex) {int max = INT_MIN;for (int i = 0; i < n; i++) {if (arr[i] > max && i != in) {max = arr[i];*lastindex = i;}}return max; }int recurZigZag(vector<vector<int> > arr, int row, int col, int n, int** dp) {//memoization partif (dp[row][col] != -1) //if already solved, no need to compute againreturn dp[row][col];if (row == n - 1) {dp[row][col] = arr[row][col];return arr[row][col];}int max = INT_MIN;for (int k = 0; k < n; k++) {if (k != col) {int t = recurZigZag(arr, row + 1, k, n, dp);if (max < t)max = t;}}dp[row][col] = std::max(dp[row][col], arr[row][col] + max); //store solutionreturn dp[row][col]; }int main() {int t, n, item;cout << "Enter test case:\n";cin >> t;for (int i = 0; i < t; i++) {cout << "Input size of square matrix\n";cin >> n;vector<vector<int> > arr;cout << "Input the square matrix\n";for (int i = 0; i < n; i++) {vector<int> inn;for (int j = 0; j < n; j++) {cin >> item;inn.push_back(item);}arr.push_back(inn);}int** dp = (int**)(malloc(sizeof(int*) * n));for (int i = 0; i < n; i++) {dp[i] = (int*)(malloc(sizeof(int) * n));for (int j = 0; j < n; j++)dp[i][j] = -1;}int mymax = INT_MIN;for (int i = 0; i < n; i++) {int p = recurZigZag(arr, 0, i, n, dp);if (p > mymax)mymax = p;}cout << "Maximum zigzag sum: " << mymax << endl;}return 0; }

Output

輸出量

Enter test case: 2 Input size of square matrix 3 Input the square matrix 3 8 2 4 8 5 6 9 7 Maximum zigzag sum: 22 Input size of square matrix 3 Input the square matrix 3 2 1 10 8 5 6 6 4 Maximum zigzag sum: 18

翻譯自: https://www.includehelp.com/icp/largest-zigzag-sequence.aspx

ue 抗鋸齒 渲染序列失靈

總結

以上是生活随笔為你收集整理的ue 抗锯齿 渲染序列失灵_最大的锯齿形序列的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美一级一级 | 欧美久久影院 | 国产美女激情 | 成人在线一区二区三区 | 在线观看中文字幕第一页 | 免费中文字幕av | 老头老太吃奶xb视频 | 青青青免费视频观看在线 | 91在线日本 | 欧美aⅴ在线 | 精品在线免费视频 | 激情亚洲 | 在线视频欧美一区 | 精品国产91久久久久久久妲己 | 最新黄色网址在线观看 | 国产精品9999 | 蜜臀久久精品久久久久久酒店 | 91久久国产视频 | 少妇被爽到高潮动态图 | 亚洲黄片一区 | 四虎精品在线播放 | 午夜激情在线观看视频 | 成人动态视频 | 亚洲性xx | 欧美大片www| 欧美色图3p | 国产农村妇女精品一区二区 | 亚洲v| 欧美不在线 | 国产视频欧美 | 国产免费av网址 | 日本韩国视频 | 九七在线视频 | 一女双乳被两男吸视频 | 国产蜜臀av一区二区 | 日本一区二区三区免费视频 | 日本三级黄色大片 | 亚洲18在线看污www麻豆 | 久久99亚洲精品 | 黄色在线a | 大奶在线播放 | 污网站免费看 | youjizzxxx69 | 人成在线视频 | 欧美一区二区三区激情 | 无码少妇一级AV片在线观看 | 日韩精品一区二区三区四区五区 | 久久精品男人 | 一级艳片新婚之夜 | 亚洲av色一区二区三区精品 | 亚洲v视频 | 亚洲精品一区在线 | 日韩欧美中文字幕一区二区三区 | 夜夜操影院 | 秋霞三区 | 日日操狠狠操 | 成人免费视频播放 | 麻豆免费在线视频 | 欧美精品一二三四 | 狠狠干2017| 蜜桃色一区二区三区 | av网站在线看 | 一区二区av | 狠狠人妻久久久久久 | 99综合网| 国产91在线播放精品91 | wwwwww在线观看 | 91av在线免费观看 | 自拍偷拍视频在线观看 | 中文字幕黄色av | 91视频地址 | 免费播放毛片 | 国产一级性生活片 | 午夜少妇视频 | 久草99| 久久国产精品偷 | 国产又大又黄的视频 | 九九视频在线观看 | 在线看片黄 | 国产无遮挡又黄又爽免费网站 | 天天综合久久 | 久久久久综合 | 毛片入口 | 91精品入口| 一区二区三区精品视频 | 国产香蕉视频 | www.rihan| 91成人在线观看高潮 | 狠狠入| 亚洲精品视频在线观看免费 | 欧美日韩在线免费视频 | a片在线免费观看 | 日本热久久| 日韩网站在线 | 成人国产精品久久 | 色网站在线看 | 日韩欧美爱爱 | 丰满岳乱妇一区二区 | 欧美日韩一区二区三区国产精品成人 |