Submission #845698

#TimeUsernameProblemLanguageResultExecution timeMemory
845698vjudge1Konstrukcija (COCI20_konstrukcija)C++17
50 / 110
1 ms600 KiB
#include <iostream> #include <algorithm> using namespace std; int main(){ int64_t k; int64_t pow2 = 1; cin >> k; bool isneg = k < 0; if (isneg) k = -k; int* from = new int[1000]; int* to = new int[1000]; from[0] = 1; to[0] = 2; from[1] = 2; to[1] = 3; from[2] = 2; to[2] = 4; int edgecount = 3; int vertexcount = 4; while (pow2 * 2 <= k) pow2 *= 2; while (pow2 > 0){ from[edgecount] = vertexcount - 1; to[edgecount] = vertexcount + 1; from[edgecount + 1] = vertexcount - 1; to[edgecount + 1] = vertexcount + 2; from[edgecount + 2] = vertexcount - 1; to[edgecount + 2] = vertexcount + 3; from[edgecount + 3] = vertexcount; to[edgecount + 3] = vertexcount + 1; from[edgecount + 4] = vertexcount; to[edgecount + 4] = vertexcount + 2; from[edgecount + 5] = vertexcount; to[edgecount + 5] = vertexcount + 3; from[edgecount + 6] = vertexcount + 1; to[edgecount + 6] = vertexcount + 4; from[edgecount + 7] = vertexcount + 2; to[edgecount + 7] = vertexcount + 4; from[edgecount + 8] = vertexcount + 3; to[edgecount + 8] = vertexcount + 4; from[edgecount + 9] = vertexcount + 1; to[edgecount + 9] = vertexcount + 5; from[edgecount + 10] = vertexcount + 2; to[edgecount + 10] = vertexcount + 5; from[edgecount + 11] = vertexcount + 3; to[edgecount + 11] = vertexcount + 5; vertexcount += 5; edgecount += 12; if ((k / pow2) % 2 == 1){ from[edgecount] = vertexcount - 1; to[edgecount] = vertexcount + 1; from[edgecount + 1] = vertexcount - 1; to[edgecount + 1] = vertexcount + 2; from[edgecount + 2] = vertexcount; to[edgecount + 2] = vertexcount + 1; from[edgecount + 3] = vertexcount; to[edgecount + 3] = vertexcount + 2; from[edgecount + 4] = 1; to[edgecount + 4] = vertexcount + 3; from[edgecount + 5] = vertexcount + 1; to[edgecount + 5] = vertexcount + 4; from[edgecount + 6] = vertexcount + 2; to[edgecount + 6] = vertexcount + 4; from[edgecount + 7] = vertexcount + 3; to[edgecount + 7] = vertexcount + 4; from[edgecount + 8] = vertexcount + 1; to[edgecount + 8] = vertexcount + 5; from[edgecount + 9] = vertexcount + 2; to[edgecount + 9] = vertexcount + 5; from[edgecount + 10] = vertexcount + 3; to[edgecount + 10] = vertexcount + 5; vertexcount += 5; edgecount += 11; } pow2 /= 2; } if (isneg){ from[edgecount] = vertexcount - 1; to[edgecount] = vertexcount + 1; from[edgecount + 1] = vertexcount; to[edgecount + 1] = vertexcount + 1; edgecount += 2; vertexcount += 1; } cout << vertexcount << " " << edgecount << endl; for (int i = 0; i < edgecount; i++){ cout << from[i] << " " << to[i] << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...