Submission #8914751


Source Code Expand

#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

template <class T> inline bool chmax(T& a, T b){
    if(a < b){a = b; return true;}
    return false;
}
template <class T> inline bool chmin(T& a, T b){
    if(a > b){a = b; return true;}
    return false;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// k : n = k(k-1) + 1

// * k = 1 : n = 1
// 1

// * k = 2 : n = 3
// 1 2
// 2 3
// 3 4

// * k = 3 : n = 7
// 1 2 3
// 1 4 5
// 1 6 7
// -----
// 2 4 6
// 2 5 7
// 3 5 6
// 3 4 7

// * k = 4 : n = 13
// 1  2  3  4
// 1  5  6  7
// 1  8  9  10
// 1  11 12 13
// -----------
// 2  5  8  11 +0
// 2  6  9  12 +0
// 2  7  10 13 +0
// 3  5  9  13 +1
// 3  6  10 11 +1
// 3  7  8  12 +1
// 4  5  10 12 +2
// 4  6  8  13 +2
// 4  7  9  11 +2

// 33, 1057
constexpr int K = 38;
constexpr int N = K * (K - 1) + 1;
std::array<std::array<int, K>, N> A;

int main(void){
    int idx, val = 2;
    for(idx = 0; idx < K; ++idx){
        A[idx][0] = 1;
        for(int j = 1; j < K; ++j) A[idx][j] = val++;
    }
    for(val = 2; val <= K; ++val){
        for(int lp = 0; lp < K - 1; ++lp){
            int row = (val - 1) * (K - 1) + lp + 1;
            A[row][0] = val;
            int hd = lp;
            for(int j = 1; j < K; ++j){
                A[row][j] = A[j][hd + 1];
                hd += (val - 2); if(hd >= K - 1) hd -= (K - 1);
            }
        }
    }

    printf("%d %d\n", N, K);
    REP(i, N){
        REP(j, K){
            printf("%d", A[i][j]);
            putchar(j == K - 1 ? '\n' : ' ');
        }
    }
    /*
    REP(i, N){
        std::set<int> S;
        REP(j, K) S.insert(A[i][j]);
        REP(j, N) if(i < j){
            int cnt = 0;
            REP(k, K) if(S.find(A[j][k]) != S.end()) cnt++;
            if(cnt != 1) printf("%d : (%d, %d)\n", cnt, i, j);
        }
    }
    */
    

    

    return 0;
}

Submission Info

Submission Time
Task F - Distribute Numbers
User arounderstand
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 2546 Byte
Status AC
Exec Time 6 ms
Memory 640 KB

Judge Result

Set Name All
Score / Max Score 1000 / 1000
Status
AC × 1
Set Name Test Cases
All 01-01.txt
Case Name Status Exec Time Memory
01-01.txt AC 6 ms 640 KB