답안 #1055759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055759 2024-08-13T05:03:40 Z 김은성(#11066) Pizza Party (CCO24_day1problem2) C++17
0 / 12
332 ms 29020 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 ", vec.size() - ans[i]);
	printf("\n");
	for(i=1; i<=n; i++)
		printf("%d ", vec.size() - rev[i]);
	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:39:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   39 |   printf("%d ", vec.size() - ans[i]);
      |           ~^    ~~~~~~~~~~~~~~~~~~~
      |            |               |
      |            int             std::vector<int>::size_type {aka long unsigned int}
      |           %ld
Main.cpp:42:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   42 |   printf("%d ", vec.size() - rev[i]);
      |           ~^    ~~~~~~~~~~~~~~~~~~~
      |            |               |
      |            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);
      |   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 195 ms 12260 KB Expected EOLN
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Expected EOLN
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 332 ms 29020 KB Expected EOLN
2 Halted 0 ms 0 KB -