Submission #583330

# Submission time Handle Problem Language Result Execution time Memory
583330 2022-06-25T08:45:14 Z WongChun1234 The Collection Game (BOI21_swaps) C++14
12 / 100
50 ms 352 KB
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
//     swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include<bits/stdc++.h>
using namespace std;
const int N=550;
int rrl[N];
vector<pair<int,int>> sch;

void solve(int n, int v) {
    // TODO implement this function
    for (int i=1;i<=n;i++) rrl[i]=i;
    for (int i=2;i<=n;i++){
    	for (int j=(i%2)+1;j<i;j+=2){
    		schedule(rrl[j],rrl[j+1]);
    		sch.push_back({rrl[j],rrl[j+1]});
		}
		vector<int> res=visit();
		for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
			if (res[j]){
				//frnt < back, 60% must
				//rrl[j] now has smaller one
			}else{
				//rrl[j] has bigger one
				swap(rrl[pos],rrl[pos+1]);
			}
		}
		sch.clear();
	}
    for (int i=n-1;i>=2;i--){
    	for (int j=(i%2)+1;j<i;j+=2){
    		schedule(rrl[j],rrl[j+1]);
    		sch.push_back({rrl[j],rrl[j+1]});
		}
		vector<int> res=visit();
		for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
			if (res[j]){
				//frnt < back, 60% must
				//rrl[j] now has smaller one
			}else{
				//rrl[j] has bigger one
				swap(rrl[pos],rrl[pos+1]);
			}
		}
		sch.clear();
	}
	vector<int> ans(n);
	for (int i=1;i<=n;i++) ans[rrl[i]-1]=i;
	answer(ans);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
      |                            ~^~~~~~~~~~~
swaps.cpp:43:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
      |                            ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Incorrect 1 ms 208 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 5 ms 208 KB Correct
3 Correct 15 ms 308 KB Correct
4 Correct 50 ms 352 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 5 ms 208 KB Correct
3 Correct 15 ms 308 KB Correct
4 Correct 50 ms 352 KB Correct
5 Incorrect 1 ms 208 KB Not correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 18 ms 304 KB Correct
4 Correct 50 ms 324 KB Correct
5 Runtime error 26 ms 316 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 18 ms 304 KB Correct
4 Correct 50 ms 324 KB Correct
5 Runtime error 26 ms 316 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 20 ms 312 KB Correct
4 Correct 50 ms 316 KB Correct
5 Runtime error 23 ms 312 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 20 ms 312 KB Correct
4 Correct 50 ms 316 KB Correct
5 Runtime error 23 ms 312 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 19 ms 308 KB Correct
4 Correct 43 ms 324 KB Correct
5 Runtime error 21 ms 320 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 19 ms 308 KB Correct
4 Correct 43 ms 324 KB Correct
5 Runtime error 21 ms 320 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -