Submission #200074

#TimeUsernameProblemLanguageResultExecution timeMemory
200074SamAndCoins (LMIO19_monetos)C++17
15.08 / 100
98 ms888 KiB
#include <bits/stdc++.h> using namespace std; const int N = 302; mt19937 rnd(134321); int t, n, k1, k2; int a[N][N]; int main() { scanf("%d%d%d%d", &t, &n, &k1, &k2); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]); } while (1) { bool z = false; if (rnd() % 2) { for (int i = 1; i <= n; ++i) { for (int j = 1; j < n; ++j) { if (a[i][j] == 1 && a[i][j + 1] == 0) { z = true; swap(a[i][j], a[i][j + 1]); } } } for (int j = 1; j <= n; ++j) { for (int i = 1; i < n; ++i) { if (a[i][j] == 1 && a[i + 1][j] == 0) { z = true; swap(a[i][j], a[i + 1][j]); } } } } else { for (int j = 1; j <= n; ++j) { for (int i = 1; i < n; ++i) { if (a[i][j] == 1 && a[i + 1][j] == 0) { z = true; swap(a[i][j], a[i + 1][j]); } } } for (int i = 1; i <= n; ++i) { for (int j = 1; j < n; ++j) { if (a[i][j] == 1 && a[i][j + 1] == 0) { z = true; swap(a[i][j], a[i][j + 1]); } } } } if (!z) break; } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { printf("%d ", a[i][j]); } printf("\n"); } return 0; }

Compilation message (stderr)

monetos.cpp: In function 'int main()':
monetos.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &t, &n, &k1, &k2);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
monetos.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...