Submission #2092310


Source Code Expand

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
   void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W, N;
int globalIdx = 0;
int a[10010];
int B[109][109];

void init() {
   rep (i, H) {
      rep (j, W) {
         B[i][j] = -1;
      }
   }
}

void dfs(int y, int x) {
   rep (i, 4) {
      int py = y + dy[i], px = x + dx[i];
      if (py < 0 || py >= H || px < 0 || px >= W || B[py][px] != -1) continue;
      int ny = y, nx = x;
      while (1) {
         ny += dy[i], nx += dx[i];
         if (ny<0 || ny>=H || nx<0 || nx>=W || B[ny][nx]!=-1) break;
         B[ny][nx] = a[globalIdx];
         globalIdx++;
      }
      dfs(ny-dy[i], nx-dx[i]);
   }
}

int main() {
   cin >> H >> W >> N;
   init();
   int idx = 0;
   rep (i, N) {
      int x;
      cin >> x;
      rep (j, x) {
         a[idx] = i+1;
         idx++;
      }
   }
   
   B[0][0] = a[0];
   globalIdx++;
   dfs(0, 0);
   rep (i, H) {
      rep (j, W) {
         cout << B[i][j];
      }
      cout << endl;
   }

   return 0;
}

Submission Info

Submission Time
Task D - Grid Coloring
User nomi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1930 Byte
Status WA
Exec Time 4 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 1
WA × 2
AC × 3
WA × 22
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 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 WA 1 ms 256 KB
0_01.txt WA 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt WA 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt WA 2 ms 384 KB
1_04.txt WA 3 ms 384 KB
1_05.txt WA 4 ms 384 KB
1_06.txt WA 2 ms 384 KB
1_07.txt WA 1 ms 256 KB
1_08.txt WA 1 ms 256 KB
1_09.txt WA 1 ms 256 KB
1_10.txt WA 1 ms 256 KB
1_11.txt WA 1 ms 256 KB
1_12.txt WA 1 ms 256 KB
1_13.txt WA 3 ms 384 KB
1_14.txt WA 1 ms 256 KB
1_15.txt WA 1 ms 256 KB
1_16.txt WA 1 ms 256 KB
1_17.txt WA 2 ms 384 KB
1_18.txt WA 1 ms 256 KB
1_19.txt WA 1 ms 256 KB
1_20.txt WA 1 ms 256 KB
1_21.txt WA 1 ms 256 KB