Editorial for Rạp chiếu phim
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này
Code mẫu của flashmt
const fi=''; fo=''; maxn=1010; p:array[0..1] of longint=(-1,1); var n,m,k,x,y,t,i:longint; a:array[1..maxn,1..maxn] of longint; begin assign(input,fi); reset(input); readln(m,n); readln(k); x:=1; y:=1; for i:=1 to k do begin read(t); repeat repeat a[x,y]:=i; y:=y+p[x mod 2]; t:=t-1; until (t=0) or (y>n) or (y<1); if (y>n) or (y<1) then begin x:=x+1; if odd(x) then y:=1 else y:=n; end; until t=0; end; close(input); assign(output,fo); rewrite(output); for i:=1 to m do begin for k:=1 to n do write(a[i,k],' '); writeln; end; close(output); end.
Code mẫu của happyboy99x
#include<cstdio> #define N 1000 int m, n, a[N][N], k; inline void next(int &i, int &j) { if(i % 2 == 0) { if(j == n-1) ++i; else ++j; } else { if(j == 0) ++i; else --j; } } int main() { scanf("%d%d%d",&m,&n,&k); int x = 0, y = 0; for(int i = 1; i <= k; ++i) { int t; scanf("%d", &t); while(t--) { a[x][y] = i; next(x,y); } } for(int i = 0; i < m; ++i) { printf("%d", a[i][0]); for(int j = 1; j < n; ++j) printf(" %d", a[i][j]); printf("\n"); } return 0; }
Code mẫu của RR
var i,j,now,k,m,n,u:longint; a:array[1..1011,1..1011] of longint; r:array[1..1000111] of longint; procedure paint(i,j:longint); begin inc(now); if now>r[u] then begin now:=1; inc(u); end; if u>k then a[i,j]:=0 else a[i,j]:=u; end; begin read(m,n,k); for k:=1 to k do read(r[k]); r[k+1]:=1000111; u:=1; now:=0; for i:=1 to m do if i and 1=1 then for j:=1 to n do paint(i,j) else for j:=n downto 1 do paint(i,j); for i:=1 to m do begin for j:=1 to n do write(a[i,j],' '); writeln; end; end.
Code mẫu của hieult
#include <iostream.h> //#include <conio.h> int A[1001][1001]; using namespace std; main () { int n,m,k,i,j,gt,xm,xn; cin>>m>>n>>k; if (k==0) for (i=1; i<=m;i++) { for (j=1;j<=n;j++) printf("0 ");; printf("\n"); } else { memset(A,0,sizeof(A)); xm=xn=1; for (i=1;i<=k;i++) { cin>>gt; for (j=1;j<=gt;j++) { A[xm][xn]=i; if (((xn==n)&&(A[xm][xn-1]!=0))||((xn==1)&&(A[xm][xn+1]!=0)) ||n==1) xm++; else if (xm%2==0) xn--; else xn++; } } for (i=1;i<=m;i++) { for (j=1;j<=n;j++) printf("%d ",A[i][j]); printf("\n"); } } // getch(); }
Code mẫu của ll931110
Program CINEMA; Const input = ''; output = ''; maxn = 1000; Var a: array[1..maxn,1..maxn] of longint; m,n,k: longint; Procedure solve; Var f: text; u,v,i,s: longint; Begin Assign(f, input); Reset(f); Fillchar(a, sizeof(a), 0); Readln(f, m, n); u:= 1; v:= 1; Readln(f, k); For i:= 1 to k do Begin Read(f, s); While s > 0 do Begin dec(s); If odd(u) then Begin a[u,v]:= i; inc(v); If v = n + 1 then Begin inc(u); v:= n; End; End else Begin a[u,v]:= i; dec(v); If v = 0 then Begin inc(u); v:= 1; End; End; End; End; End; Procedure printresult; Var f: text; i,j: longint; Begin Assign(f, output); Rewrite(f); For i:= 1 to m do Begin For j:= 1 to n do write(f, a[i,j], ' '); Writeln(f); End; Close(f); End; Begin solve; printresult; End.
Code mẫu của skyvn97
#include<stdio.h> #define MAX 1111 int m,n,k; int cx,cy; int a[MAX][MAX]; void process(void) { int i,j,t; scanf("%d",&m); scanf("%d",&n); scanf("%d",&k); for (i=1;i<=m;i=i+1) for (j=1;j<=n;j=j+1) a[i][j]=0; cx=1; cy=1; for (i=1;i<=k;i=i+1) { scanf("%d",&t); for (j=1;j<=t;j=j+1) { a[cx][cy]=i; if (cx%2==1) { if (cy==n) cx++; else cy++; } else { if (cy==1) cx++; else cy--; } } } for (i=1;i<=m;i=i+1) { for (j=1;j<n;j=j+1) printf("%d ",a[i][j]); printf("%d\n",a[i][n]); } } int main(void) { process(); }
Code mẫu của khuc_tuan
//{$mode delphi} {$APPTYPE CONSOLE} {$R+,Q+,S+} uses SysUtils; var j, h, z, i, k, m, n, ci, cj : integer; a : array[1..1000,1..1000] of integer; begin read(m,n); read(k); ci := 1; cj := 1; h := 1; for i:=1 to k do begin read(z); for j:=1 to z do begin a[ci,cj] := i; inc(cj,h); if cj<1 then begin inc(ci); cj := 1; h := 1; end else if cj>n then begin inc(ci); cj := n; h := -1; end; end; end; for i:=1 to m do begin for j:=1 to n do write(a[i,j],' '); writeln; end; end.
Comments