제출 #892034

#제출 시각아이디문제언어결과실행 시간메모리
892034Mihailo즐거운 행로 (APIO20_fun)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "fun.h" #define mp make_pair using namespace std; long long c, d[200000], l[4], k[200000], x, p[200000], M, m, ctr; priority_queue<pair<long long, long long> > q[4]; long long * createFunTour(long long n, long long q) { c=1; for(int i=2; i<=n; i++) { if(attractionsBehind(c, i)>=n/2) c=i; } x=1; for(int i=1; i<=n; i++) { if(i!=c) d[i]=hoursRequired(c, i); if(d[i]==1) {l[x]=i;k[i]=x;x++;} } for(int i=1; i<=n; i++) { if(k[i]==0&&i!=c) { if(hoursRequired(i, l[1])<d[i]) k[i]=1; else if(hoursRequired(i, l[2])<d[i]) k[i]=2; else k[i]=3; } } for(int i=1; i<=n; i++) { q[k[i]].push(mp(d[i], i)); } x=0; ctr=1; while(2*max(max(q[1].size(), q[2].size()), q[3].size())<q[1].size()+q[2].size()+q[3].size()) { m=0; for(int i=1; i<=3; i++) { if(i!=x) { if(m<q[i].front().first) { m=q[i].front().first; M=i; } } } x=M; p[ctr]=q[x].front().second; ctr++; q[x].pop(); } for(int i=1; i<=3; i++) { if(q[i].size()==max(max(q[1].size(), q[2].size()), q[3].size())) M=i; } for(int i=1; i<=3; i++) { if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) { p[ctr]=q[i].front().second; ctr++; q[i].pop(); x=i; } } if(M!=x) { p[ctr]=q[M].front().second; ctr++; q[M].pop(); x=M; } while(2*max(max(q[1].size(), q[2].size()), q[3].size())>0) { m=0; if(x==M) for(int i=1; i<=3; i++) { if(i!=M) { if(m<q[i].front().first) { m=q[i].front().first; x=i; } } } else x=M; p[ctr]=q[x].front().second; ctr++; q[x].pop(); } p[ctr]=c; return p; }

컴파일 시 표준 에러 (stderr) 메시지

fun.cpp: In function 'long long int* createFunTour(long long int, long long int)':
fun.cpp:27:10: error: invalid types 'long long int[long long int]' for array subscript
   27 |         q[k[i]].push(mp(d[i], i));
      |          ^
fun.cpp:31:22: error: invalid types 'long long int[int]' for array subscript
   31 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())<q[1].size()+q[2].size()+q[3].size()) {
      |                      ^
fun.cpp:31:35: error: invalid types 'long long int[int]' for array subscript
   31 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())<q[1].size()+q[2].size()+q[3].size()) {
      |                                   ^
fun.cpp:31:49: error: invalid types 'long long int[int]' for array subscript
   31 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())<q[1].size()+q[2].size()+q[3].size()) {
      |                                                 ^
fun.cpp:31:62: error: invalid types 'long long int[int]' for array subscript
   31 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())<q[1].size()+q[2].size()+q[3].size()) {
      |                                                              ^
fun.cpp:31:74: error: invalid types 'long long int[int]' for array subscript
   31 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())<q[1].size()+q[2].size()+q[3].size()) {
      |                                                                          ^
fun.cpp:31:86: error: invalid types 'long long int[int]' for array subscript
   31 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())<q[1].size()+q[2].size()+q[3].size()) {
      |                                                                                      ^
fun.cpp:35:23: error: invalid types 'long long int[int]' for array subscript
   35 |                 if(m<q[i].front().first) {
      |                       ^
fun.cpp:36:24: error: invalid types 'long long int[int]' for array subscript
   36 |                     m=q[i].front().first;
      |                        ^
fun.cpp:42:17: error: invalid types 'long long int[long long int]' for array subscript
   42 |         p[ctr]=q[x].front().second;
      |                 ^
fun.cpp:44:10: error: invalid types 'long long int[long long int]' for array subscript
   44 |         q[x].pop();
      |          ^
fun.cpp:47:13: error: invalid types 'long long int[int]' for array subscript
   47 |         if(q[i].size()==max(max(q[1].size(), q[2].size()), q[3].size())) M=i;
      |             ^
fun.cpp:47:34: error: invalid types 'long long int[int]' for array subscript
   47 |         if(q[i].size()==max(max(q[1].size(), q[2].size()), q[3].size())) M=i;
      |                                  ^
fun.cpp:47:47: error: invalid types 'long long int[int]' for array subscript
   47 |         if(q[i].size()==max(max(q[1].size(), q[2].size()), q[3].size())) M=i;
      |                                               ^
fun.cpp:47:61: error: invalid types 'long long int[int]' for array subscript
   47 |         if(q[i].size()==max(max(q[1].size(), q[2].size()), q[3].size())) M=i;
      |                                                             ^
fun.cpp:50:19: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                   ^
fun.cpp:50:40: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                                        ^
fun.cpp:50:53: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                                                     ^
fun.cpp:50:67: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                                                                   ^
fun.cpp:50:81: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                                                                                 ^
fun.cpp:50:109: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                                                                                                             ^
fun.cpp:50:129: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                                                                                                                                 ^
fun.cpp:50:150: error: invalid types 'long long int[int]' for array subscript
   50 |         if(x!=i&&q[i].size()!=max(max(q[1].size(), q[2].size()), q[3].size())&&q[i].front().first==max(max(q[1].front().first, q[2].front().first), q[3].front().first)) {
      |                                                                                                                                                      ^
fun.cpp:51:21: error: invalid types 'long long int[int]' for array subscript
   51 |             p[ctr]=q[i].front().second;
      |                     ^
fun.cpp:53:14: error: invalid types 'long long int[int]' for array subscript
   53 |             q[i].pop();
      |              ^
fun.cpp:58:17: error: invalid types 'long long int[long long int]' for array subscript
   58 |         p[ctr]=q[M].front().second;
      |                 ^
fun.cpp:60:10: error: invalid types 'long long int[long long int]' for array subscript
   60 |         q[M].pop();
      |          ^
fun.cpp:63:22: error: invalid types 'long long int[int]' for array subscript
   63 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())>0) {
      |                      ^
fun.cpp:63:35: error: invalid types 'long long int[int]' for array subscript
   63 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())>0) {
      |                                   ^
fun.cpp:63:49: error: invalid types 'long long int[int]' for array subscript
   63 |     while(2*max(max(q[1].size(), q[2].size()), q[3].size())>0) {
      |                                                 ^
fun.cpp:68:27: error: invalid types 'long long int[int]' for array subscript
   68 |                     if(m<q[i].front().first) {
      |                           ^
fun.cpp:69:28: error: invalid types 'long long int[int]' for array subscript
   69 |                         m=q[i].front().first;
      |                            ^
fun.cpp:75:17: error: invalid types 'long long int[long long int]' for array subscript
   75 |         p[ctr]=q[x].front().second;
      |                 ^
fun.cpp:77:10: error: invalid types 'long long int[long long int]' for array subscript
   77 |         q[x].pop();
      |          ^