답안 #872526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872526 2023-11-13T09:55:01 Z Onur_Ilgaz Knjige (COCI20_knjige) C++17
0 / 50
2 ms 1496 KB
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;

int32_t main(){
	fast
	int n;
	cin >> n;
	vector <int> arr(n), order;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		order.push_back(arr[i]);
	}
	sort(order.begin(), order.end());
	vector<string> output;
	for(int i = 0; i < n; i++) {
		// i şimdiye kadar silinen eleman sayısı aynı zamanda
		int eleman = order[i];
		int from;
		for(int j = 0; j < arr.size(); j++) {
			if(arr[j] == eleman) {
				from = j; 
				break;
			}
		}
		if(!from) {
			arr.erase(arr.begin() + from);
			continue;
		}
		// to = i
		for(int i = 0; i < arr.size(); i++) {
			if(i == from) {
				output.push_back("ULMI D L\n");
			}
			else {
				output.push_back("ULMI L L\n");
				output.push_back("STAVI L D\n");
			}
		}
		output.push_back("STAVI D L\n");
		for(int i = 0; i < arr.size() - 1; i++) {
			output.push_back("ULMI L D\n");
			output.push_back("STAVI L L\n");
		}
		arr.erase(arr.begin() + from);
	}
	cout << output.size() << "\n";
	for(auto &it:output) {
		cout << it;
	}
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:22:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int j = 0; j < arr.size(); j++) {
      |                  ~~^~~~~~~~~~~~
Main.cpp:33:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int i = 0; i < arr.size(); i++) {
      |                  ~~^~~~~~~~~~~~
Main.cpp:43:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i = 0; i < arr.size() - 1; i++) {
      |                  ~~^~~~~~~~~~~~~~~~
Main.cpp:28:3: warning: 'from' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |   if(!from) {
      |   ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1496 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
2 Incorrect 2 ms 1492 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
3 Incorrect 1 ms 1496 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
4 Incorrect 1 ms 1496 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
5 Incorrect 1 ms 1492 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
6 Incorrect 2 ms 1492 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
7 Incorrect 1 ms 988 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
8 Incorrect 1 ms 1492 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
9 Incorrect 2 ms 1496 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"
10 Incorrect 1 ms 1492 KB Token "ULMI" doesn't correspond to pattern "(UZMI|STAVI)"