zoukankan      html  css  js  c++  java
  • Preliminaries for Benelux Algorithm Programming Contest 2019:A:Architecture

    Your brother has won an award at the recent Breakthroughs in Architectural Problems Conference and has been given the once in a lifetime opportunity of redesigning the city center of his favorite city Nijmegen. Since the most striking parts of a city’s layout are the skylines(天际线),your brother has started by drawing ideas for how he wants the northern and eastern skylines of Nijmegen to look. However, some of his proposals look rather outlandish, and you are starting to wonder whether his designs are possible.

    For his design, your brother has put an R × C grid on the city. Each cell of the city will contain a building of a certain height. The eastern skyline is given by the tallest building in each of the R rows, and the northern skyline is given by the tallest building in each of the C columns.

    A pair of your brother’s drawings of skylines is possible if and only if there exists some way of assigning building heights to the grid cells such that the resulting skylines match these drawings.

    Figure A.1 shows a possible city with the northern and eastern skylines exactly as given in the input of the first sample.  

    图A.1.jpg

    INPUT:

    • The first line consists of two integers 1 =<R,C =<100, the number of rows and columns in the grid.

    • The second line consists of R integers x1, . . . , xR describing the eastern skyline (0=<xi =<1000 for all i).

    • The third line consists of C integers y1, . . . , yC describing the northern skyline (0 =< yj =<1000 for all j).

    OUTPUT:

    Output one line containing the string possible if there exists a city design that produces the specified skyline, and impossible otherwise.

    样例输入1

    4 4
    4 3 2 1
    1 2 3 4

    样例输出1

    possible

    样例输入2

    4 4
    1 2 3 4
    1 2 3 2

    样例输出2

    impossible

    
    
    
     
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cctype>
    #include <iostream>
    #include <algorithm>
    #include <map>
    #include <set>
    #include <vector>
    #include <string>
    #include <stack>
    #include <queue>
     
    typedef long long LL;
    using namespace std;
     
    int n, m;
    int a[105], b[105];
     
    int main()
    {
    	scanf("%d %d", &n, &m);
    	int mxl = -1, mxr = -1;
    	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), mxl = max(mxl, a[i]);
    	for (int i = 1; i <= m; i++) scanf("%d", &b[i]), mxr = max(mxr, b[i]);
    	if(mxl == mxr) printf("possible
    ");
    	else printf("impossible
    ");
     
    	return 0;
    }
    

      

    运行样例截图:
    
    

    总结:

    我之前之前的分析想着什么的边界上可能有些龃龉,但矩阵的最大值是唯一的,目前先先朦胧地把握一下嘿嘿。

    我觉得呀,这不是严格意义上的矩阵呀,就是呀关键是那个最右上角的那个数。

    不不不,我突然又明了了,就是我题目理解错了!!题目给的样例图是是呀是对的!!!!!

    就是它确实就是skyline就是各各行的最大值,各各列的最大值。

    给的东西不是矩阵里面的数,是矩阵中提取出来的,我脑回路一不小心走向清奇方向了qwq2333!

    总有些时候瑙鲁脑回路不是一般的清奇,总结积累之

    
    
    





     
  • 相关阅读:
    太白老师 day06 编码 encode decode
    太白老师day6 1.代码块 2.is==id 3.小数据池
    MySQL 基本语法(1.表字段操作,2表记录管理 3.运算符管理4.SQL查询 5.约束6.索引
    List 接口常用子类及其特点
    Java 集合框架
    Java 常用工具类之基本对象包装类
    Java 常用工具类之 String 类
    Java 多线程间通信
    Java 多线程通信之多生产者/多消费者
    Java 之多线程通信(等待/唤醒)
  • 原文地址:https://www.cnblogs.com/dragondragon/p/12513159.html
Copyright © 2011-2022 走看看