Submission #396943

#TimeUsernameProblemLanguageResultExecution timeMemory
396943Andyvanh1Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <math.h> using namespace std; #define pb push_back #define INF INT32_MAX #define vt vector typedef vt<int> vi; typedef pair<int,int> pii; typedef tuple<int,int,int> tiii; typedef long long ll; int n; #define MOD 1000000007 vt<vi> adjlist(1); vt<char> node(1); vt<int> endd(1); vt<int> par(1); vt<int> depth(1); vt<bool> mark; int id; int cur = 0; void build(string str){ int cur = 0; int at = 0; while(at!=str.length()){ bool bol = false; for(auto& e: adjlist[cur]){ if(e==par[cur])continue; if(node[e]==str[at]){ at++; cur = e; bol = true; break; } } if(!bol)break; } if(at==str.length()){ endd[cur]++; return; } at--; while(at!=str.length()-1){ adjlist.pb(vi(0)); adjlist[cur].pb(id); adjlist[id].pb(cur); depth.pb(at+1); par.pb(cur); node.pb(str[at+1]); endd.pb(0); cur = id; at++;id++; } endd[id-1]++; } vt<bool> visited; void dfs(int noder){ cur++; visited[noder] = true; if(endd[noder]){ for(int i = 0; i < endd[noder]; i++) cout<<"P"<<'\n'; } int scrib = -1; for(auto& e: adjlist[noder]){ if(mark[e]&&!visited[e]){ scrib = e; continue; } if(!visited[e]){ cout<<string(1,node[e])<<'\n'; dfs(e); } } if(scrib!=-1){ cout<<string(1,node[scrib])<<'\n'; dfs(scrib); } if(cur!=adjlist.size()) { cout << "-" << '\n'; } } void specbuild(string str){ mark.resize(adjlist.size()); for(int i = 0; i < adjlist.size(); i++){ mark[i] = false; } int cur = 0; int at = 0; while(at!=str.length()){ bool bol = false; for(auto& e: adjlist[cur]){ if(e==par[cur])continue; if(node[e]==str[at]){ at++; cur = e; mark[cur] = true; bol = true; break; } } if(!bol)break; } } int dp[1000005][4]; ll delivery(int n, int k, int l, vi arr){ if(k==1){ ll ans = 0; for(int i = 0; i < n; i++){ ans+=2*min(arr[i],l-arr[i]); } return ans; }else if(k==n){ if(arr[n-1]<=l/2){ return arr[n-1]*2; }else if(arr[0]>l/2){ return 2* (l-arr[0]); }else{ return l; } } return 0; }

Compilation message (stderr)

boxes.cpp: In function 'void build(std::string)':
boxes.cpp:37:9: warning: declaration of 'cur' shadows a global declaration [-Wshadow]
   37 |     int cur = 0;
      |         ^~~
boxes.cpp:34:5: note: shadowed declaration is here
   34 | int cur = 0;
      |     ^~~
boxes.cpp:40:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     while(at!=str.length()){
      |           ~~^~~~~~~~~~~~~~
boxes.cpp:56:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     if(at==str.length()){
      |        ~~^~~~~~~~~~~~~~
boxes.cpp:61:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     while(at!=str.length()-1){
      |           ~~^~~~~~~~~~~~~~~~
boxes.cpp: In function 'void dfs(int)':
boxes.cpp:99:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 | if(cur!=adjlist.size()) {
      |    ~~~^~~~~~~~~~~~~~~~
boxes.cpp: In function 'void specbuild(std::string)':
boxes.cpp:106:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |     for(int i = 0; i < adjlist.size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~
boxes.cpp:109:9: warning: declaration of 'cur' shadows a global declaration [-Wshadow]
  109 |     int cur = 0;
      |         ^~~
boxes.cpp:34:5: note: shadowed declaration is here
   34 | int cur = 0;
      |     ^~~
boxes.cpp:112:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |     while(at!=str.length()){
      |           ~~^~~~~~~~~~~~~~
boxes.cpp: In function 'll delivery(int, int, int, vi)':
boxes.cpp:133:40: warning: declaration of 'n' shadows a global declaration [-Wshadow]
  133 | ll delivery(int n, int k, int l, vi arr){
      |                                        ^
boxes.cpp:23:5: note: shadowed declaration is here
   23 | int n;
      |     ^
/tmp/ccWiaZTG.o: In function `main':
grader.c:(.text.startup+0x1cb): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status