제출 #836308

#제출 시각아이디문제언어결과실행 시간메모리
836308LiudasMinerals (JOI19_minerals)C++17
컴파일 에러
0 ms0 KiB
#include "minerals.h" #include "minerals.h" #include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <iostream> #include <bits/stdc++.h> using namespace std; constexpr int MAX_N = 43000; constexpr int MAX_CALLS = 2000000; namespace { void WrongAnswer(int code) { printf("Wrong Answer [%d]\n", code); exit(0); } int N; int counterpart[2 * MAX_N + 1]; int num_queries; int num_kinds; int on[2 * MAX_N + 1]; int countt[2 * MAX_N + 1]; int num_answers; int answer[2 * MAX_N + 1]; } // namespace int Query(int x) { if (!(1 <= x && x <= 2 * N)) { cout << x << endl; WrongAnswer(1); } if (++num_queries > MAX_CALLS) { WrongAnswer(2); } const int type = std::min(x, counterpart[x]); if (on[x]) { --on[x]; --countt[type]; if (countt[type] == 0) { --num_kinds; } } else { ++on[x]; ++countt[type]; if (countt[type] == 1) { ++num_kinds; } } return num_kinds; } void Answer(int a, int b) { if (++num_answers > N) { WrongAnswer(6); } if (!(1 <= a && a <= 2 * N && 1 <= b && b <= 2 * N)) { WrongAnswer(3); } if (answer[a] != 0) { WrongAnswer(4); } answer[a] = b; if (answer[b] != 0) { WrongAnswer(4); } answer[b] = a; if (!(counterpart[a] == b && counterpart[b] == a)) { WrongAnswer(5); } } int last = 0; void div(vector<int> start, vector<int> end, int par){ int N = start.size(); if(start.size() != end.size()) cout << start.size() << " " << end.size() << endl; vector<int> l, r, le, re, left; if(N == 1){ Answer(start[0], end[0]); return; } if(par == 1){ for(int i = 0; i < N/2; i ++){ last = Query(start[i]); l.push_back(start[i]); } for(int i = N/2; i < N; i ++){ r.push_back(start[i]); } for(int i = 0; i < N; i ++){ int t = Query(end[i]); if(t != last){ last = t; le.push_back(end[i]); } else{ re.push_back(end[i]); } } div(le, l, 1); div(r, re, 2); } else if (par == 2){ for(int i = 0; i < N/2; i ++){ last = Query(start[i]); l.push_back(start[i]); } for(int i = N/2; i < N; i ++){ r.push_back(start[i]); } for(int i = 0; i < N; i ++){ int t = Query(end[i]); if(t != last){ last = t; le.push_back(end[i]); } else{ re.push_back(end[i]); } } div(l, le, 0); div(r, re, 1); } if(par == 0){ for(int i = 0; i < N/2; i ++){ last = Query(start[i]); l.push_back(start[i]); } for(int i = N/2; i < N; i ++){ r.push_back(start[i]); } for(int i = 0; i < N; i ++){ int t = Query(end[i]); if(t == last){ last = t; le.push_back(end[i]); if(le.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } else{ last = t; re.push_back(end[i]); if(le.size() == (N+1)/2){ for(int j = i + 1; j < N; j ++){ left.push_back(end[j]); } break; } } } if(!(re.size() + le.size() + left.size() == N)){ cout << re.size() << " " << left.size() << " " << le.size()<< " " << N << endl; cout << "WTF" << endl; } //cout << re.size() << " " << left.size() << " " << le.size() << endl; if(le.size() != N/2){ if(le.size() < (N+3)/4){ for(int i : le){ Query(i); } for(int i : left){ le.push_back(i); } div(l, le, 1); } else{ for(int i : left){ le.push_back(i); Query(i); } div(l, le, 2); } } else{ div(l, le, 2); } if(re.size() != N/2){ if(re.size() < (N + 3)/4){ for(int i : re){ Query(i); } for(int i : left){ re.push_back(i); } div(r, re, 0); } else{ for(int i : left){ re.push_back(i); Query(i); } div(re, r, 1); } } else{ div(re, r, 1); } } } void Solve(int N) { vector<int> start, end; vector<int> order(2 * N); iota(order.begin(), order.end(), 0); shuffle(order.begin(), order.end(), mt19937(225)); for(int i : order){ int t = start.size(); if(i < 0 || i >= N * 2){ cout << i << " ..." << endl; } int ans = Query(i+1); if(ans == t + 1){ start.push_back(i+1); } else{ end.push_back(i+1); } } last = N; div(start, end, 2); }

컴파일 시 표준 에러 (stderr) 메시지

minerals.cpp: In function 'void div(std::vector<int>, std::vector<int>, int)':
minerals.cpp:142:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  142 |         if(le.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:152:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  152 |         if(le.size() == (N+1)/2){
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:160:46: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  160 |     if(!(re.size() + le.size() + left.size() == N)){
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
minerals.cpp:165:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  165 |     if(le.size() != N/2){
      |        ~~~~~~~~~~^~~~~~
minerals.cpp:166:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  166 |       if(le.size() < (N+3)/4){
      |          ~~~~~~~~~~^~~~~~~~~
minerals.cpp:186:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  186 |     if(re.size() != N/2){
      |        ~~~~~~~~~~^~~~~~
minerals.cpp:187:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  187 |       if(re.size() < (N + 3)/4){
      |          ~~~~~~~~~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccOAh7qP.o: in function `Query(int)':
grader.cpp:(.text+0x30): multiple definition of `Query(int)'; /tmp/ccKwiGzQ.o:minerals.cpp:(.text+0x30): first defined here
/usr/bin/ld: /tmp/ccOAh7qP.o: in function `Answer(int, int)':
grader.cpp:(.text+0x100): multiple definition of `Answer(int, int)'; /tmp/ccKwiGzQ.o:minerals.cpp:(.text+0xc0): first defined here
collect2: error: ld returned 1 exit status