Tags » HARD

Bloomberg Business - Scientists Just Proved Einstein's Theory on Gravitational Waves

“Feb 11 — Bloomberg’s Emily Chang reports on a new scientific discovery on “Bloomberg West.””

1-5 Minutes

7 Simple Tasks We Are All Guilty Of Avoiding

Procrastination. Something none of us are strangers to… I mean, if there was an exam in it we probably all aced it at school or uni right? 533 more words

Lists

Lent: Giving up Caffeine. I'm screwed.

Me and the PG Tips Monkey, I love him, just like I love tea and love coffee. I fear I would not bleed red but in fact bleed tea if cut open. 323 more words

Lifestyles

1964 City Game

问题来自 poj 1964 City Game

这道题是典型的动态规划,我下面提供了两个版本。第一个时间复杂度是O(n3),第二个时间复杂度是O(n2)。这道题在leetcode上也出现了leetcode 85. Maximal Rectangle.
这道题的输入很麻烦,真正的输入并不是按照给出的input那样“标准的格式”输入的

1, O(n3)

下面的代码利用了maximum sub array的思想,但Time Limit Exceeded

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
const int N = 1001;

char board[N][N];
int row, col, k;
int tmp[N];
char str;

void init()
{
    scanf("%d%d", &row, &col);
    getchar();  
    for(int r = 0; r < row; ++r)  
        for(int c = 0; c < col; ++c)  
        {  
            char ch = getchar();  
            while(ch!='F' && ch!='R')  
                ch=getchar();  
                board[r][c]=ch;  
        }        
}

int maxiSubArray(int arr[], int n)
{
    if(n == 0) return 0;
    int ret = 0;
    int pre = 0;
    for(int i = 1; i < n; ++i)
        if(arr[i] != arr)
        {
            ret = max(ret, (i-pre)*arr);
            pre = i;
        }
    ret = max(ret, (n-pre)*arr);
    return ret;
}

int solve()
{
    int maxi = 0;
    for(int startr = 0; startr < row; ++startr)
    {
        memset(tmp, 0, sizeof(tmp));
        for(int endr = startr; endr < row; ++endr)
        {
            for(int c = 0; c < col; ++c)
                if(board[c] == 'F')
                    ++tmp[c];
                else
                    tmp[c] = 0;
            maxi = max(maxi, maxiSubArray(tmp, col));
        }
    }
    return maxi*3;
}

int main()
{
    scanf("%d", &k);
    while(k--)
    {
        init();

        printf("%d\n", solve());
    }
    return 0;
}
… 615 more words
POJ解题报告

1989 The Cow Lineup

问题来自 poj 1989 The Cow Lineup

看到这题是毫无头绪,以为要用动态规划,看了discuss才知道就是简单的读入标记即可。。。。

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
const int K = 10001;
bool exist[K];
int n, k;
int solve()
{
    memset(exist, false, sizeof(exist));
    int digit;
    int found = 0;
    int result = 1;
    for(int i = 0; i < n; ++i)
    {
        scanf("%d", &digit);
        if(!exist)
        {
            exist = true;
            ++found;
        }
        if(found == k)
        {
            found = 0;
            ++result;
            memset(exist, false, sizeof(exist));
        }
    }
    return result;
}
int main()
{
    while(scanf("%d%d", &n, &k) != EOF)
        printf("%d\n", solve());
    return 0;
}
POJ解题报告

In the Blink of an Eye

On Monday, I was a leader, a confidant, a mentor. It was my job to ensure the daily procedures and activities of a dental clinic were carried out in an appropriate, timely, and professional manner. 387 more words

an irresponsible love

Her heart was invested in a 21 year old boy who had no interest in becoming a man. Not any time soon, at least. He used me to build up his ego. 35 more words

College