Submission #590741

#TimeUsernameProblemLanguageResultExecution timeMemory
590741l_rehoMemory (IOI10_memory)C++14
0 / 100
1 ms208 KiB
#include "memory.h"
#include "grader.h"
#include <stdio.h>
#include <stdlib.h>

static char card[51];
static int up[2], is_up[51], candy[25], candies, moves;

#include <bits/stdc++.h>
using namespace std;

map<char, int> mp;
vector<bool> open(51, false);

char faceup(int C);

void play() {
	
	int prev_open = -1;


	for(int i = 1; i <= 50; i++){
		char c = faceup(i);
		
		int idxC = mp[c];
		
		
		
		// se ne ho già trovata una di c ed è aperta, allora
		// basta cosi
		
		if(idxC && open[idxC]){
			open[idxC] = 0;
			prev_open = -1;
			continue;
		}
		
		// se ne ho già trovata una di c e non è aperta, allora
		// se ce ne sono altre aperte, allora devo riaprire la corrente e quella precedentemente trovata
	
		if(idxC && !open[idxC]){
			if(prev_open != -1){
				open[prev_open] = 0;
				faceup(i);
				faceup(idxC);
			}else
				faceup(idxC);
				
			continue;
		}
		
		// se non ho trovato c e non ho altre aperte dietro, allora i rimane aperta
		if(!idxC && prev_open == -1){
			prev_open = i;
			open[i] = 1;
			mp[c] = i;
			
			continue;
		}
		
		// se non ho trovato c e ne ho altre aperte dietro, allora i si chiude insieme a quell'altra
		
		if(!idxC && prev_open != -1){
			open[prev_open] = 0;
			open[i] = 0;
			mp[c] = i;
			
			prev_open = -1;
		}
		
	}
}

Compilation message (stderr)

memory.cpp:7:50: warning: 'moves' defined but not used [-Wunused-variable]
    7 | static int up[2], is_up[51], candy[25], candies, moves;
      |                                                  ^~~~~
memory.cpp:7:41: warning: 'candies' defined but not used [-Wunused-variable]
    7 | static int up[2], is_up[51], candy[25], candies, moves;
      |                                         ^~~~~~~
memory.cpp:7:30: warning: 'candy' defined but not used [-Wunused-variable]
    7 | static int up[2], is_up[51], candy[25], candies, moves;
      |                              ^~~~~
memory.cpp:7:19: warning: 'is_up' defined but not used [-Wunused-variable]
    7 | static int up[2], is_up[51], candy[25], candies, moves;
      |                   ^~~~~
memory.cpp:7:12: warning: 'up' defined but not used [-Wunused-variable]
    7 | static int up[2], is_up[51], candy[25], candies, moves;
      |            ^~
memory.cpp:6:13: warning: 'card' defined but not used [-Wunused-variable]
    6 | static char card[51];
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...