Submission #815868

#TimeUsernameProblemLanguageResultExecution timeMemory
815868PikachuCarnival (CEOI14_carnival)C++17
20 / 100
77 ms316 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> inline bool maxi(T &x, const T &val) { if (x < val) return x = val, true; return false; } template<typename T> inline bool mini(T &x, const T &val) { if (x > val) return x = val, true; return false; } const int maxn = 155; int n; int ans[maxn]; int par[maxn]; int findpar(int x) { if (par[x]) return par[x] = findpar(par[x]); return x; } void unite(int u, int v) { u = findpar(u); v = findpar(v); if (u != v) par[u] = v; } int getInt() { int tmp; cin >> tmp; return tmp; } void solve() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { cout << 2 << ' ' << i << ' ' << j << endl; if (getInt() == 1) unite(i, j); } } int cnt = 0; for (int i = 1; i <= n; i++) { int x = findpar(i); if (ans[x]) ans[i] = ans[x]; else { ans[i] = ans[x] = ++cnt; } } cout << "0 "; for (int i = 1; i <= n; i++) cout << ans[i] << ' '; cout << endl; } signed main() { #ifdef LOCAL clock_t st = clock(); #endif ios_base::sync_with_stdio(false); cin.tie(0); #define Task "" #ifdef LOCAL if (!fopen("D:\\.inp", "r")) { freopen("D:\\.inp", "w", stdout); freopen("D:\\.out", "w", stdout); cerr << "get input from file\n"; return 0; } freopen("D:\\.inp", "r", stdin); freopen("D:\\.out", "w", stdout); #else if (fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } #endif solve(); #ifdef LOCAL cerr << clock() - st << endl; #endif }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen(Task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:87:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |         freopen(Task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...