Submission #1055754

# Submission time Handle Problem Language Result Execution time Memory
1055754 2024-08-13T04:59:22 Z 김은성(#11066) Pizza Party (CCO24_day1problem2) C++17
0 / 12
278 ms 28600 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int inv[1000009], b[1000009], rev[1000009];
int cnt[1000009];
int ans[1000009];
int main(){
	int n, m, i, val;
	scanf("%d", &n, &m);
	for(i=1; i<=n; i++){
		scanf("%d", &b[n+1-i]);
		cnt[b[n+1-i]]--;
	}
	for(i=1; i<=n; i++){
		scanf("%d", &val);
		inv[val] = i;
		cnt[val]++;
	}
	for(i=1; i<=n; i++)
		b[n+1-i] = -inv[b[n+1-i]];
	for(i=1; i<=n; i++){
		if(cnt[i]){
			printf("-1\n");
			return 0;
		}
	}
	vector<int> vec;
	for(i=1; i<=n; i++){
		int idx = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
		if(idx == vec.size())
			vec.push_back(b[i]);
		else
			vec[idx] = b[i];
		ans[n+1-i] = idx;
		rev[-b[i]] = idx;
	}
	printf("%d\n", vec.size());
	for(i=1; i<=n; i++)
		printf("%d ", ans[i] + 1);
	printf("\n");
	for(i=1; i<=n; i++)
		printf("%d ", rev[i] + 1);
	printf("\n");
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:9:8: warning: too many arguments for format [-Wformat-extra-args]
    9 |  scanf("%d", &n, &m);
      |        ^~~~
Main.cpp:30:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   if(idx == vec.size())
      |      ~~~~^~~~~~~~~~~~~
Main.cpp:37:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   37 |  printf("%d\n", vec.size());
      |          ~^     ~~~~~~~~~~
      |           |             |
      |           int           std::vector<int>::size_type {aka long unsigned int}
      |          %ld
Main.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~
Main.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", &b[n+1-i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d", &val);
      |   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 12116 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 278 ms 28600 KB Expected EOLN
2 Halted 0 ms 0 KB -