Submission #909623

# Submission time Handle Problem Language Result Execution time Memory
909623 2024-01-17T09:55:53 Z MilosMilutinovic 라멘 (JOI14_ramen) C++14
100 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#include "ramen.h"
using namespace std;
 
void Ramen(int n) {
  if (n == 1) {
    Answer(0, 0);
    return;
  }
  auto Ask = [&](int i, int j) {
    return Compare(i, j);
  };      
  vector<int> s;
  for (int i = 0; i < n - n % 2; i += 2) {
    s.push_back(Ask(i, i + 1));  
  }                   
  int mn = 0, mx = 1;
  if (s[0] == -1) {
    swap(mn, mx);
  }
  for (int i = 1; i < (int) s.size(); i++) {
    int x = 2 * i, y = 2 * i + 1;
    if (s[i] == -1) {
      swap(x, y);  
    }
    if (Ask(x, mn) == 1) {
      mn = x;
    }
    if (Ask(mx, y) == 1) {
      mx = y;                       
    }
  }
  if (n % 2 == 1) {
    if (Ask(n - 1, mn) == 1) {
      mn = n - 1;
    }
    if (Ask(mx, n - 1) == 1) {
      mx = n - 1;
    }
  }
  Answer(mx, mn);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct