Submission #26122

# Submission time Handle Problem Language Result Execution time Memory
26122 2017-06-28T05:22:55 Z 서규호(#1097) None (JOI16_memory2) C++14
60 / 100
0 ms 2024 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

int N;
int ans[102];

void divide(vector<int> tmp){
	if(tmp.size() == 2){
		ans[tmp[0]] = ans[tmp[1]] = Flip(tmp[0],tmp[1]);
		return;
	}
	int big = -1,it;
	for(int i=0; i<tmp.size(); i+=2){
		int t = Flip(tmp[i],tmp[i+1]);
		if(big < t){
			big = t;
			it = i;
		}
	}
	vector<int> tmp2;
	for(int i=0; i<tmp.size(); i++){
		if(i == it || i == it+1){
			tmp2.pb(tmp[i]);
		}else{
			int t = Flip(tmp[i],tmp[it]);
			if(t < big){
				ans[tmp[i]] = t;
			}else tmp2.pb(tmp[i]);
		}
	}
	if(tmp.size() == 4 && tmp2.size() == 4){
		for(int i=0; i<2; i++) for(int j=2; j<4; j++){
			if(Flip(tmp[i],tmp[j]) == big+1){
				ans[tmp[i]] = ans[tmp[j]] = big+1;
				ans[tmp[1-i]] = ans[tmp[5-j]] = big;
			}
		}
		return;
	}
	divide(tmp2);
}

void Solve(int T, int n){
	N = n;
	if(T <= 2){
		vector<int> tmp;
		for(int i=0; i<N*2; i++) tmp.pb(i);
		divide(tmp);
	}
	for(int i=0; i<2*N; i++){
		for(int j=i+1; j<2*N; j++){
			if(ans[i] == ans[j]) Answer(i,j,ans[i]);
		}
	}
}

Compilation message

memory2.cpp: In function 'void divide(std::vector<int>)':
memory2.cpp:17:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<tmp.size(); i+=2){
                ^
memory2.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<tmp.size(); i++){
                ^
memory2.cpp:26:24: warning: 'it' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(i == it || i == it+1){
                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
6 Correct 0 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
8 Correct 0 ms 2024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
6 Correct 0 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
8 Correct 0 ms 2024 KB Output is correct
9 Correct 0 ms 2024 KB Output is correct
10 Correct 0 ms 2024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2024 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -