列表

详情


NC52863. Super Resolution

描述

Bobo has an picture consists of black and white pixels.
He loves the picture so he would like to scale it times.
That is, to replace each pixel with block of pixels with the same color (see the example for clarity).

输入描述

The input contains zero or more test cases and is terminated by end-of-file. For each test case,

The first line contains four integers n, m, a, b.
The i-th of the following n lines contains a binary string of length m which denotes the i-th row of the original picture. Character "`0`" stands for a white pixel while the character "`1`" stands for black one.

*
* The number of tests cases does not exceed 10.

输出描述

For each case, output  rows and  columns which denote the result.

示例1

输入:

2 2 1 1
10
11
2 2 2 2
10
11
2 2 2 3
10
11

输出:

10
11
1100
1100
1111
1111
111000
111000
111111
111111

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

Pascal(fpc 3.0.2) 解法, 执行用时: 2ms, 内存消耗: 220K, 提交时间: 2019-10-04 12:14:21

var
a:string;
i,j,i1,j1,n,m,n1,m1:longint;
begin
readln(n,m,n1,m1);
while not eof do
 begin
  for i:=1 to n do
   begin
    readln(a);
    for i1:=1 to n1 do
     begin
      for j:=1 to m do
       for j1:=1 to m1 do
        write(a[j]);
      writeln;
     end;
   end;
  readln(n,m,n1,m1);
 end;
end.

C++14(g++5.4) 解法, 执行用时: 3ms, 内存消耗: 476K, 提交时间: 2019-10-04 14:44:21

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[15][15];
int main(){
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
		for(int i=0;i<a;i++)scanf("%s",s[i]);
		for(int i=0;i<a*c;i++){
			for(int o=0;o<b*d;o++)
				printf("%c",s[i/c][o/d]);
			printf("\n");
		}
	}
}

C++11(clang++ 3.9) 解法, 执行用时: 4ms, 内存消耗: 460K, 提交时间: 2020-02-25 21:11:38

#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,i,j;
string s,t;
int main()
{
	while(cin>>n>>m>>a>>b)
	{
		for(i=0;i<n;i++)
		{
			cin>>s;
			t="";
			for(auto c:s) t+=string(b,c);
			for(j=0;j<a;j++) cout<<t<<endl;
		}
	}
	return 0;
}

Python3(3.5.2) 解法, 执行用时: 24ms, 内存消耗: 3420K, 提交时间: 2019-10-04 12:43:01

while 1:
	try:n,m,a,b=map(int,input().split())
	except:break
	for i in range(n):
		s=input();S=""
		for j in s:S+=j*b
		print(end=(S+'\n')*a)

上一题