Submission #647090

#TimeUsernameProblemLanguageResultExecution timeMemory
647090AlmaLampice (COCI21_lampice)C++14
50 / 50
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second using ll = long long; using ii = pair<int,int>; const int INF = 1e9; const ll LLINF = 1e18; using vi = vector<int>; using vvi = vector<vi>; void setIO (string fileName) { ios::sync_with_stdio(false); cin.tie(NULL); if (fileName != "std") { freopen((fileName + ".in").c_str(), "r", stdin); freopen((fileName + ".out").c_str(), "w", stdout); } } int main() { setIO("std"); int n, k; cin >> n >> k; vi lamp(n); for (int& i: lamp) cin >> i; for (int len = 1; len <= n; len++) { for (int i = 0; i < n and i + len*k <= n; i++) { bool pos = true; for (int t = 0; t < k and pos; t++) { for (int j = 0; j < len and pos; j++) { if (lamp[i+j] != lamp[i + len*t + j]) pos = false; } } if (pos) { cout << len << '\n'; for (int j = 0; j < len; j++) { cout << lamp[i+j] << ' '; } return 0; } } } cout << "-1\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen((fileName + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen((fileName + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...