int main(int argc, char *argv[])
{
	struct addrinfo *ailist, *aip;
	struct addrinfo hint;
	int sockfd, err;
	struct sigaction sa;

	sa.sa_handler = sigalarm;
	sa.sa_flags = 0;
	sigemptyset(&sa.sa_mask);
	sigaction(SIGALARM, &sa, NULL);
	memeset(&hint, 0, sizeof(hint));
	hint.ai_socktype = SOCK_DGRAM;
	hint.ai_canonname = NULL;
	hint.ai_addr = NULL;
	hint.ai_next = NULL;
	getaddrinfo(argv[1], "ruptime", &hint, &ailist);
	for (aip = ailist; aip != NULL; aip = aip->next)
	{
		sockfd = socket(aip->ai_family, SOCK_DGRAM, 0);
		print_uptime(sockfd, aip);
		exit(0);
	}
	exit(-1);
}
示例#2
0
//AC - 4ms;
int maximalSquare(char** matrix, int rSize, int cSize)
{
    int max = 0;
    int *maxes = (int*)malloc(sizeof(int)*cSize);
    memeset(maxes, 0, sizeof(int)*cSize);
    for(int i = 0; i < cSize; i++)
        if(matrix[0][i] == '1') maxes[i] = 1;
    for(int r = 1; r < rSize; r++)
    {
        maxes[0] = matrix[r][0]-'0';
        int pre = matrix[r-1][0]-'0';
        for(int c = 1; c < cSize; c++)
        {
            if(matrix[r][c] == '1')
            {
                int min = pre;
                if(maxes[c-1] < min) min = maxes[c-1];
                if(maxes[c] < min) min = maxes[c];
                pre = maxes[c];
                maxes[c] = min+1;
                if(maxes[c] > max) max = maxes[c];
            }
            else
                maxes[c]=0;
        }
    }
    return max*max;
}