Submission #1002949

# Submission time Handle Problem Language Result Execution time Memory
1002949 2024-06-19T21:37:43 Z gabistroeh MalnaRISC (COI21_malnarisc) C++14
33.3247 / 100
5 ms 5468 KB
#include<bits/stdc++.h>
using namespace std;

int mark[2010][2010];
vector <pair<int, int> > comandos[200010];
int inf = 1e9+10;
int N;

bool check(){
	for(int i=1; i<=N; i++){
		for(int j=i+1; j<=N; j++){
			if(mark[i][j]==0) return 0;
		}
	}
	return 1;
}

int main(){
	cin >> N;
	int resp = 0;
	int qtde[N+1];
	for(int i=1; i<=N; i++) qtde[i] = 0;
	while(!check()){
		resp++;
		int usado[N+1];
		for(int i=1; i<=N; i++) usado[i] = 0;
		for(int i=1; i<=N; i++){
			int menos = 0;
			int num = inf;
			if(usado[i]==1) continue;
			for(int j=i+1; j<=N; j++){
				if(usado[j]==0 && mark[i][j]==0){
					if(qtde[j]<num){
						num = qtde[j];
						menos = j;
					}
				}
			}
			if(menos==0) continue;
			qtde[menos]++;
			qtde[i]++;
			usado[i] = 1;
			usado[menos] = 1;
			mark[i][menos] = 1;
			comandos[resp].push_back({i, menos});
		}
	}

	cout << resp << endl;
	for(int i=1; i<=resp; i++){
		for(int j=0; j<comandos[i].size(); j++){
			cout << "CMPSWP R" << comandos[i][j].first << " R" << comandos[i][j].second << " ";
		}
		cout << endl;
	}
}

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for(int j=0; j<comandos[i].size(); j++){
      |                ~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 4956 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 5212 KB Partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5208 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 5212 KB Partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5464 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5468 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5468 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5468 KB not sorted
2 Halted 0 ms 0 KB -