Submission #784158

#TimeUsernameProblemLanguageResultExecution timeMemory
784158jnjwnwnwCarnival (CEOI14_carnival)C++11
100 / 100
22 ms316 KiB
#include <iostream> #include <algorithm> #include <string> #include <set> using namespace std; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } #define MAXN 151 int n; set<int> groups[MAXN]; int ans[MAXN]; int main(){ cin >> n; int group = 0; int prev = 0; for(int i = 1; i <= n; i++){ cout << i; for(int j = 1; j <= i; j++){ cout << " " << j; } cout << endl; int cur; cin >> cur; if (cur != prev){ groups[group++].insert(i); } prev = cur; } int numGroups = group; group = 0; int temp; for(int i = 1; i <= n; i++){ if (groups[group].find(i) != groups[group].end()){ // already has, so next group group++; }else{ // need to find a group to keep this in; for(int j = 0; j < group; j++){ cout << 2 << " " << (*groups[j].upper_bound(0)) << " " << i << endl; cin >> temp; if (temp == 1){ // found our spot groups[j].insert(i); break; } } } } for(int i = 0; i < numGroups; i++){ for(int j: groups[i]){ ans[j] = i+1; } } cout << 0; for(int i = 1; i <= n; i++){ cout << " " << ans[i]; } cout << endl; }

Compilation message (stderr)

carnival.cpp: In function 'void setIO(std::string)':
carnival.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen((s + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  freopen((s + ".out").c_str(), "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...