Submission #3481416
Source Code Expand
/** * File : D.cpp * Author : Kazune Takahashi * Created : 2018-10-27 20:58:14 * Powered by Visual Studio Code */ #include <iostream> #include <iomanip> // << fixed << setprecision(xxx) #include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ; #include <vector> #include <string> // to_string(nnn) // substr(m, n) // stoi(nnn) #include <complex> #include <tuple> #include <queue> #include <stack> #include <map> // if (M.find(key) != M.end()) { } #include <set> #include <functional> #include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725)); #include <chrono> // std::chrono::system_clock::time_point start_time, end_time; // start = std::chrono::system_clock::now(); // double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count(); #include <cctype> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> using namespace std; #define DEBUG 0 // change 0 -> 1 if we need debug. typedef long long ll; // const int dx[4] = {1, 0, -1, 0}; // const int dy[4] = {0, 1, 0, -1}; // const int C = 1e6+10; // const ll M = 1000000007; int N; int n; void det() { for (auto i = 1; i < 1000; i++) { if (i * (i + 1) / 2 == N) { n = i; cout << "Yes" << endl; return; } } cout << "No" << endl; exit(0); } int main() { cin >> N; det(); vector<vector<int>> V(n + 1, vector<int>(n)); int now = 0; for (auto i = 0; i < n + 1; i++) { for (auto j = 0; j < i; j++) { V[i][j] = V[j][i - 1]; } for (auto j = i; j < n; j++) { V[i][j] = now++; } } assert(now == N); cout << n + 1 << endl; for (auto i = 0; i < n + 1; i++) { cout << n << " "; for (auto j = 0; j < n; j++) { cout << V[i][j] + 1; if (j < n - 1) { cout << " "; } else { cout << endl; } } } }
Submission Info
Submission Time | |
---|---|
Task | D - Crossing |
User | kazunetakahashi |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2017 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 2176 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 17 ms | 1920 KB |
12.txt | AC | 20 ms | 2176 KB |
13.txt | AC | 1 ms | 256 KB |
14.txt | AC | 1 ms | 256 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | AC | 1 ms | 256 KB |
17.txt | AC | 1 ms | 256 KB |
18.txt | AC | 3 ms | 384 KB |
19.txt | AC | 8 ms | 896 KB |
20.txt | AC | 1 ms | 256 KB |
21.txt | AC | 12 ms | 1280 KB |
22.txt | AC | 10 ms | 1152 KB |
23.txt | AC | 1 ms | 256 KB |
24.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |