Submission #1486679


Source Code Expand

Copy
/// b.cpp
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < decltype(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
# define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    vii e;
    int n,m;
    int k;
    fi>>n>>m>>k;
    for (int i = 1;i <= n;i += 2)
    {
        for (int j = 1;j <= m;++j)
            e.pb(mp(i,j));
        if (i + 1 <= n)
            for (int j = m;j;--j)
                e.pb(mp(i + 1,j));
    }
    static int s[1 << 10][1 << 10];
    for (int i = 1;i <= k;++i)
    {
        int v;
        fi>>v;
        while (v --)
        {
            auto index = e.back();
            e.pop_back();
            s[index.x][index.y] =  i;
        }
    }
    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= m;++j)
            fo << s[i][j] << " \n"[j == m];
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Submission Info

Submission Time
Task D - Grid Coloring
User reality
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1967 Byte
Status
Exec Time 4 ms
Memory 896 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 640 KB
1_03.txt 2 ms 896 KB
1_04.txt 3 ms 896 KB
1_05.txt 4 ms 896 KB
1_06.txt 2 ms 768 KB
1_07.txt 1 ms 256 KB
1_08.txt 1 ms 384 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 4 ms 896 KB
1_14.txt 1 ms 256 KB
1_15.txt 1 ms 640 KB
1_16.txt 1 ms 256 KB
1_17.txt 2 ms 768 KB
1_18.txt 1 ms 384 KB
1_19.txt 1 ms 384 KB
1_20.txt 1 ms 256 KB
1_21.txt 1 ms 640 KB