Submission #1272658

#TimeUsernameProblemLanguageResultExecution timeMemory
1272658rana_azkaXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include "xylophone.h" const int MAXN = 5000; static int A[5000]; int n; map<pair<int, int>, int> mp; int konf1[MAXN+5]; int konf2[MAXN+5]; int ans[MAXN+5]; void solve(int N) { n = N; for(int i = 1; i <= n - 1; i++) mp[{i, i + 1}] = query(i, i+1); for(int i = 1; i <= n - 2; i++) mp[{i, i + 2}] = query(i, i+2); // KONFIGURASI 1 bool is_pos = 1; konf1[1] = 0; konf1[2] = mp[{1, 2}]; for(int i = 3; i <= n; i++){ if(mp[{i-2, i}] != mp[{i-2, i-1}] + mp[{i-1, i}]) is_pos = !is_pos; konf1[i] = konf1[i-1] + (is_pos ? mp[{i-1, i}] : mp[{i-1, i}]); } int mn = INF, idx_mn = 0; int mx = -INF, idx_mx = 0; for(int i = 1; i <= n; i++){ if(konf1[i] < mn){ mn = konf1[i]; idx_mn = i; } if(konf1[i] > mx){ mx = konf1[i]; idx_mx = i; } } if(idx_mn < idx_mx){ int temp = 1 - mn; for(int i = 1; i <= n; i++) ans[i] = konf1[i] + temp; for(int i = 1; i <= N; i++) answer(i, ans[i]); return ; } // KONFIGURASI 2 is_pos = 0; konf2[1] = 0; konf2[2] = -mp[{1, 2}]; for(int i = 3; i <= n; i++){ if(mp[{i-2, i}] != mp[{i-2, i-1}] + mp[{i-1, i}]) is_pos = !is_pos; konf2[i] = konf2[i-1] + (is_pos ? mp[{i-1, i}] : mp[{i-1, i}]); } mn = INF, idx_mn = 0; mx = -INF, idx_mx = 0; for(int i = 1; i <= n; i++){ if(konf2[i] < mn){ mn = konf2[i]; idx_mn = i; } if(konf2[i] > mx){ mx = konf2[i]; idx_mx = i; } } if(idx_mn < idx_mx){ int temp = 1 - mn; for(int i = 1; i <= n; i++) ans[i] = konf2[i] + temp; for(int i = 1; i <= N; i++) answer(i, ans[i]); return ; } }

Compilation message (stderr)

xylophone.cpp:7:5: error: 'pair' was not declared in this scope
    7 | map<pair<int, int>, int> mp;
      |     ^~~~
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:5: error: 'pair' was not declared in this scope
xylophone.cpp:7:1: error: 'map' does not name a type
    7 | map<pair<int, int>, int> mp;
      | ^~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:14:41: error: 'mp' was not declared in this scope
   14 |         for(int i = 1; i <= n - 1; i++) mp[{i, i + 1}] = query(i, i+1);
      |                                         ^~
xylophone.cpp:15:41: error: 'mp' was not declared in this scope
   15 |         for(int i = 1; i <= n - 2; i++) mp[{i, i + 2}] = query(i, i+2);
      |                                         ^~
xylophone.cpp:19:34: error: 'mp' was not declared in this scope
   19 |         konf1[1] = 0; konf1[2] = mp[{1, 2}];
      |                                  ^~
xylophone.cpp:25:18: error: 'INF' was not declared in this scope
   25 |         int mn = INF, idx_mn = 0;
      |                  ^~~
xylophone.cpp:30:25: error: 'idx_mn' was not declared in this scope
   30 |                         idx_mn = i;
      |                         ^~~~~~
xylophone.cpp:35:25: error: 'idx_mx' was not declared in this scope
   35 |                         idx_mx = i;
      |                         ^~~~~~
xylophone.cpp:39:21: error: 'idx_mx' was not declared in this scope
   39 |         if(idx_mn < idx_mx){
      |                     ^~~~~~
xylophone.cpp:39:12: error: 'idx_mn' was not declared in this scope
   39 |         if(idx_mn < idx_mx){
      |            ^~~~~~
xylophone.cpp:54:19: error: 'idx_mn' was not declared in this scope
   54 |         mn = INF, idx_mn = 0;
      |                   ^~~~~~
xylophone.cpp:55:21: error: 'idx_mx' was not declared in this scope
   55 |         mx =  -INF, idx_mx = 0;
      |                     ^~~~~~