Submission #234740

# Submission time Handle Problem Language Result Execution time Memory
234740 2020-05-25T12:30:37 Z anayk None (JOI16_memory2) C++14
10 / 100
5 ms 384 KB
#include "Memory2_lib.h"
#include <vector>

void Solve(int T, int N){
  while(T--) {
    std::vector<int> ans(2*N, -1);

    int x = 0, y = 1, z = -1;
    int lastComp = Flip(x, y);

    for(int i = 2; i < 2*N; i++) {
      int xComp = Flip(i, x);
      int yComp = Flip(i, y);

      if(z == -1) {
        if(xComp == lastComp && yComp != lastComp) {
          ans[x] = lastComp;
          lastComp = yComp;
          x = i;
        }
        else if(yComp == lastComp && xComp != lastComp) {
          ans[y] = lastComp;
          lastComp = xComp;
          y = i;
        }
        else if(xComp == lastComp && yComp == lastComp) {
          z = i;
        }
        else {
          ans[i] = xComp;
        }
      }
      else {
        if(xComp == lastComp && yComp == lastComp) {
          ans[x] = ans[y] = lastComp;
          x = z;
          y = i;
          z = -1;
          lastComp = Flip(x, y);
        }
        else if(xComp == lastComp && yComp != lastComp) {
          ans[x] = ans[z] = lastComp;
          x = i;
          z = -1;
          lastComp = yComp;
        }
        else if(xComp != lastComp && yComp == lastComp) {
          ans[y] = ans[z] = lastComp;
          y = i;
          z = -1;
          lastComp = xComp;
        }
        else {
          ans[i] = xComp;
        }
      }
    }

    ans[x] = ans[y] = lastComp;

    std::vector<std::vector<int> > output(N);
    for(int i = 0; i < 2*N; i++) {
      if(ans[i] == -1)
        ans[i] = Flip(x, i);

      output[ans[i]].push_back(i);
    }

    for(int i = 0; i < N; i++)
      Answer(output[i][0], output[i][1], i);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Wrong Answer[4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -