Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #1486784

Source Code Expand

Copy
```#include <bits/stdc++.h>
using namespace std;

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
ios::sync_with_stdio(false);
int H, W;
cin >> H >> W;
int N; cin >> N;
vector<vector<int>> grid(H, vector<int>(W));

int h = 0, w = 0;
bool down = true;

rep(i, N) {
int A; cin >> A;
rep(j, A) {
// DUMP2(h, w);
grid[h][w] = i+1;
h += (down ? 1 : -1);

if (down && h == H) {
w++;
h = H - 1;
down = false;
}

if (!down && h == -1) {
w++;
h = 0;
down = true;
}
}
}

rep(i, H) {
rep(j, W) {
if (j > 0) cout << " ";
cout << grid[i][j];
}
cout << endl;
}
}```

#### Submission Info

Submission Time 2017-08-06 21:15:44+0900 D - Grid Coloring OUDON C++14 (GCC 5.4.1) 400 1412 Byte AC 3 ms 384 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
All 400 / 400 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt
Case Name Status Exec Time Memory
0_00.txt 1 ms 256 KB
0_01.txt 1 ms 256 KB
0_02.txt 1 ms 256 KB
1_00.txt 1 ms 256 KB
1_01.txt 1 ms 256 KB
1_02.txt 1 ms 256 KB
1_03.txt 2 ms 384 KB
1_04.txt 2 ms 384 KB
1_05.txt 3 ms 384 KB
1_06.txt 2 ms 256 KB
1_07.txt 1 ms 256 KB
1_08.txt 1 ms 256 KB
1_09.txt 1 ms 256 KB
1_10.txt 1 ms 256 KB
1_11.txt 1 ms 256 KB
1_12.txt 1 ms 256 KB
1_13.txt 2 ms 384 KB
1_14.txt 1 ms 256 KB
1_15.txt 1 ms 256 KB
1_16.txt 1 ms 256 KB
1_17.txt 2 ms 256 KB
1_18.txt 1 ms 256 KB
1_19.txt 1 ms 256 KB
1_20.txt 1 ms 256 KB
1_21.txt 1 ms 256 KB