1. Optimal Hospital Location

Algorithm: Weighted Median (Math Foundations)
Problem Content
Place one or multiple hospitals to minimize travel distance for residents, using population-weighted metrics.
Algorithmic Solution
Sort by coordinate, compute weighted median (1D). For higher dimensions approximate using separable medians or k-medians clustering.
Input / Output (Project Version)
Input: N (pos, weight). Output: median position and total weighted distance.
Related SDGs
SDG 3 β€” Good Health & Well-being SDG 11 β€” Sustainable Cities

πŸ“· Click to View Image

C++ Example (Weighted median 1D)
// Weighted median (1D) - O(n log n)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  if(!(cin>>n)) return 0;
  vector> a(n);
  ll total=0;
  for(int i=0;i<n;i++){ cin>>a[i].first>>a[i].second; total+=a[i].second; }
  sort(a.begin(), a.end());
  ll acc=0, half=(total+1)/2, median=a.back().first;
  for(auto &p:a){ acc+=p.second; if(acc>=half){ median=p.first; break; } }
  ll cost=0; for(auto &p:a) cost += llabs(p.first - median) * p.second;
  cout << median << " " << cost << "\\n";
  return 0;
}
Residents:
x   population
2   120
5   300
9   180
14  220
20  160

Expected Output:
Optimal hospital position = 9
Total weighted distance = 2680

2. School Allocation to Students

Algorithm: Dijkstra + Greedy Assignment (Heap)
Problem Content
Assign students to schools minimizing travel time while respecting school capacities and zones.
Algorithmic Solution
Run Dijkstra from each school or multi-source; create a min-heap of (distance, student, school) triples and greedily assign while decreasing capacities.
Input / Output (Project Version)
Input: street graph, student nodes, school nodes with capacities. Output: assignments and total travel cost.
Related SDGs
SDG 4 β€” Quality Education SDG 10 β€” Reduced Inequalities

πŸ“· Click to View Image

C++ Example (Dijkstra + greedy assignment)
// Dijkstra distances + greedy assignment
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (1LL<<60);
vector dijkstra(int src, const vector>> &g){
  int n=g.size(); vector dist(n, INF);
  dist[src]=0; priority_queue, vector>, greater>> pq; pq.push({0,src});
  while(!pq.empty()){
    auto [d,u]=pq.top(); pq.pop(); if(d!=dist[u]) continue;
    for(auto &e:g[u]){ int v=e.first; ll w=e.second; if(dist[v] > d + w){ dist[v]=d + w; pq.push({dist[v], v}); } }
  }
  return dist;
}
int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);
  int n,m; cin>>n>>m; vector>> g(n);
  for(int i=0;i<m;i++){ int u,v,w; cin>>u>>v>>w; g[u].push_back({v,w}); g[v].push_back({u,w}); }
  int S; cin>>S; vector students(S); for(int i=0;i<S;i++) cin>>students[i];
  int K; cin>>K; vector schools(K), cap(K); for(int i=0;i<K;i++) cin>>schools[i]>>cap[i];
  vector> distFromSchool(K, vector(n, INF));
  for(int i=0;i<K;i++) distFromSchool[i] = dijkstra(schools[i], g);
  using T=tuple; priority_queue, greater> pq;
  for(int si=0; si<S; ++si) for(int ki=0; ki<K; ++ki) if(distFromSchool[ki][students[si]] assigned(S,-1); ll total=0;
  while(!pq.empty()){
    auto [d,si,ki]=pq.top(); pq.pop();
    if(assigned[si]!=-1) continue;
    if(cap[ki]<=0) continue;
    assigned[si]=ki; cap[ki]--; total+=d;
  }
  for(int i=0;i<S;i++) cout << i << " -> " << (assigned[i]==-1? -1: schools[assigned[i]]) << "\\n";
  cout << "Total cost: " << total << "\\n";
  return 0;
}
Schools:
S1 (capacity = 2)
S2 (capacity = 3)

Students and Distances:
Student   S1   S2
A         4    6
B         2    3
C         5    1
D         3    4
E         6    2

Expected Output:
Student β†’ School allocation
Minimum total travel distance

3. Smart Parking Slot Allocation

Algorithm: Greedy Assignment + Trie for permit lookup
Problem Content
Assign incoming cars to parking slots to minimize walking distance while handling reserved permits and accessibility constraints.
Algorithmic Solution
Form feasible (car,slot,distance) triples, sort by distance and greedily match. Use a Trie for permit prefix matching to restrict reserved slots.
Input / Output (Project Version)
Input: cars list (coords + permit), slots (coords + reservedPrefix or -). Output: assignments and total walking distance.
Related SDGs
SDG 11 β€” Sustainable Cities SDG 9 β€” Industry & Infrastructure

πŸ“· Click to View Image

C++ Example (greedy sorted pairs + Trie)
// Greedy assignment with permit prefix matching
#include <bits/stdc++.h>
using namespace std;
struct Trie{ unordered_map<char,Trie*> ch; bool end=false; void ins(const string&s){ Trie*cur=this; for(char c:s){ if(!cur->ch[c]) cur->ch[c]=new Trie(); cur=cur->ch[c]; } cur->end=true; } bool starts(const string&p){ Trie*cur=this; for(char c:p){ if(!cur->ch[c]) return false; cur=cur->ch[c]; } return true; } };
int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);
  int C,S; cin>>C>>S; struct Car{int x,y; string p;}; vector<Car> cars(C);
  for(int i=0;i<C;i++) cin>>cars[i].x>>cars[i].y>>cars[i].p;
  struct Slot{int x,y; string r;}; vector<Slot> slots(S);
  Trie root;
  for(int i=0;i<S;i++){ cin>>slots[i].x>>slots[i].y>>slots[i].r; if(slots[i].r!="-") root.ins(slots[i].r); }
  struct T{int car,slot; double d;};
  vector<T> v;
  auto dist=[&](int x1,int y1,int x2,int y2){ return hypot(x1-x2,y1-y2); };
  for(int i=0;i<C;i++) for(int j=0;j<S;j++){
    if(slots[j].r=="-" || cars[i].p.rfind(slots[j].r,0)==0) v.push_back({i,j,dist(cars[i].x,cars[i].y,slots[j].x,slots[j].y)});
  }
  sort(v.begin(), v.end(), [](auto&a,auto&b){ return a.d carUsed(C,-1), slotUsed(S,-1); double total=0;
  for(auto &t:v) if(carUsed[t.car]==-1 && slotUsed[t.slot]==-1){ carUsed[t.car]=t.slot; slotUsed[t.slot]=t.car; total+=t.d; }
  for(int i=0;i<C;i++) cout << "Car " << i << " -> Slot " << (carUsed[i]==-1? -1: carUsed[i]) << "\\n";
  cout << "Total (approx): " << total << "\\n";
}
Cars (pickup points):
C1 (2,3)
C2 (5,7)
C3 (8,1)

Parking Slots:
P1 (3,3)
P2 (6,7)
P3 (9,1)

Expected Output:
Optimal car β†’ parking slot assignment
Minimum total walking distance

4. Industrial vs Residential Separation

Algorithm: Graph Coloring (BFS/DFS)
Problem Content
Assign zoning types across adjacent parcels so incompatible types do not share edges, preventing harmful co-location.
Algorithmic Solution
Build parcel adjacency graph. Attempt 2-coloring using BFS/DFS β€” if conflict arises, identify components for manual/local backtracking.
Input / Output (Project Version)
Input: parcel adjacency graph and surface attributes. Output: zone color per parcel and conflict report.
Related SDGs
SDG 11 β€” Sustainable Cities SDG 3 β€” Good Health

πŸ“· Click to View Image

C++ Example (Bipartite check)
// Bipartite check skeleton
#include <bits/stdc++.h>
using namespace std;
bool is_bipartite(const vector<vector<int>>& g){
  int n=g.size(); vector color(n,-1);
  for(int s=0;s<n;++s){
    if(color[s]!=-1) continue;
    queue q; q.push(s); color[s]=0;
    while(!q.empty()){
      int u=q.front(); q.pop();
      for(int v: g[u]){
        if(color[v]==-1){ color[v]=color[u]^1; q.push(v); }
        else if(color[v]==color[u]) return false;
      }
    }
  }
  return true;
}
int main(){ int n,m; cin>>n>>m; vector<vector>u>>v; g[u].push_back(v); g[v].push_back(u); }
  cout << (is_bipartite(g)? "BIPARTITE":"NOT_BIPARTITE") << "\\n"; return 0;
}
Land Parcels (Nodes):
0, 1, 2, 3, 4, 5

Adjacency (conflict edges):
0 - 1
1 - 2
2 - 3
3 - 4
4 - 5

Expected Output:
Valid zoning using 2 colors
No adjacent parcels share the same zone

5. Public Park Placement Optimization

Algorithm: Greedy Max-Coverage + Fenwick tree support
Problem Content
Select k park sites from candidates to maximize covered population within walking radius, ensuring equity.
Algorithmic Solution
For each candidate precompute which population points it covers; greedily pick candidate with largest uncovered population (Fenwick/segment trees speed updates).
Input / Output (Project Version)
Input: candidate coords, population grid/points, k. Output: chosen sites and covered population.
Related SDGs
SDG 11 β€” Sustainable Cities SDG 3 β€” Good Health

πŸ“· Click to View Image

C++ Example (Greedy + Fenwick skeleton)
// Greedy Max-Coverage skeleton
#include <bits/stdc++.h>
using namespace std;
struct Fenwick { int n; vector bit; Fenwick(int n=0):n(n),bit(n+1,0){}; void add(int i,long long v){ for(++i;i<=n;i+=i&-i) bit[i]+=v; } long long sum(int i){ long long r=0; for(++i;i>0;i-=i&-i) r+=bit[i]; return r; } };
int main(){
  int P,C,k; cin>>P>>C>>k;
  vector<pair w(P);
  for(int i=0;i<P;i++) cin>>pts[i].first>>pts[i].second>>w[i];
  vector<pair>cand[i].first>>cand[i].second;
  int r; cin>>r;
  vector<vectorbestgain){ bestgain=gain; best=i; }
    }
    if(best==-1) break;
    chosen.push_back(best);
    for(int p:covers[best]) covered[p]=true;
  }
  long long total=0; for(int i=0;i<P;i++) if(covered[i]) total+=w[i];
  cout << "Chosen sites: "; for(int x:chosen) cout << x << " "; cout << "\\nCovered pop: " << total << "\\n";
}
Population Centers:
P1 (2,2)  Population = 100
P2 (5,5)  Population = 200
P3 (7,7)  Population = 150

Candidate Park Locations:
L1 (3,3)
L2 (6,6)
L3 (8,8)

Parameters:
k = 2 parks
coverage radius = 3 units

Expected Output:
Selected park locations maximizing population coverage
Total covered population

6. Land Subdivision Optimization

Algorithm: Divide & Conquer.
Problem Content
Partition land parcels into balanced subplots while keeping constraints like minimum area and road access.
Algorithmic Solution
Compute polygon area via shoelace formula and recursively partition along axes to approximate equal-area subplots.
Input / Output (Project Version)
Input: polygon boundary points. Output: sub-polygons with areas and centroids.
Related SDGs
SDG 11 β€” Sustainable Cities SDG 15 β€” Life on Land

πŸ“· Click to View Image

C++ Example
// formula skeleton
#include <bits/stdc++.h>
using namespace std;
double polygon_area(const vector<pair>n; vector<pair>poly[i].first>>poly[i].second; cout << polygon_area(poly) << "\\n"; }
Land Boundary (Polygon Coordinates):
(0,0)
(6,0)
(6,4)
(0,4)

Task:
Divide the land into balanced sub-plots

Expected Output:
Total Area = 24 unitsΒ²
Balanced land subdivision

7. High Footfall Commercial Zone Prediction

Algorithm: Grid Binning + 2D Prefix Sums
Problem Content
Analyze movement traces and POI density to identify likely commercial hotspots for transit planning and services.
Algorithmic Solution
Bin traces into grid cells, build 2D prefix sums for fast rectangle queries, and sort candidate cells by aggregated counts.
Input / Output (Project Version)
Input: movement traces (x,y), POI data. Output: ranked hotspot cells and suggested interventions.
Related SDGs
SDG 8 β€” Decent Work & Economic Growth SDG 11 β€” Sustainable Cities

πŸ“· Click to View Image

C++ Example (2D prefix sums)
// 2D prefix sums skeleton
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W,H; cin>>W>>H; int T; cin>>T;
  vector<vector(W,0));
  for(int i=0;i<T;i++){ int x,y; cin>>x>>y; if(x>=0&&x<W&&y>=0&&y<H) grid[y][x]++; }
  vector<vector(W+1,0));
  for(int r=1;r<=H;r++) for(int c=1;c<=W;c++) ps[r][c]=grid[r-1][c-1]+ps[r-1][c]+ps[r][c-1]-ps[r-1][c-1];
  int k; cin>>k; vector<pair
              
Bus Stops:
A, B, C, D, E

Passenger Count:
A  50
B  30
C  40
D  20
E  60

Distances (in km):
A-B  4
B-C  3
C-D  5
D-E  2
A-E  9

Expected Output:
Optimal bus route covering all stops
Minimum total travel distance

8. Creation of Green Belt Buffers

Algorithm: Multi-source BFS / Grid Morphological Buffer
Problem Content
Generate successive buffer layers around pollution sources while respecting obstacles and protected zones to create green corridors.
Algorithmic Solution
Run BFS starting from all pollutant sources simultaneously. Each BFS layer forms one buffer band; mask expansion into protected cells.
Input / Output (Project Version)
Input: raster map (source cells, obstacles). Output: distance-layered map for planting regions.
Related SDGs
SDG 13 β€” Climate Action SDG 15 β€” Life on Land

πŸ“· Click to View Image

C++ Example (Multi-source BFS)
// Multi-source BFS skeleton
#include <bits/stdc++.h>
using namespace std;
int main(){
  int R,C; cin>>R>>C; vector<string> grid(R);
  for(int i=0;i<R;i++) cin>>grid[i];
  queue<pair(C,-1));
  for(int r=0;r<R;r++) for(int c=0;c<C;c++) if(grid[r][c]=='S'){ dist[r][c]=0; q.push({r,c}); }
  int dr[4]={1,-1,0,0}, dc[4]={0,0,1,-1};
  while(!q.empty()){ auto [r,c]=q.front(); q.pop();
    for(int k=0;k<4;k++){ int nr=r+dr[k], nc=c+dc[k];
      if(nr>=0 && nr<R && nc>=0 && nc<C && grid[nr][nc]!='#' && dist[nr][nc]==-1){ dist[nr][nc]=dist[r][c]+1; q.push({nr,nc}); } }
  }
  for(int r=0;r<R;r++){ for(int c=0;c<C;c++) cout << (dist[r][c]==-1? -1: dist[r][c]) << " "; cout << "\\n"; }
}
Water Sources:
S1 (capacity = 120)
S2 (capacity = 100)
S3 (capacity = 80)

Demand Zones:
Zone1 = 100
Zone2 = 80
Zone3 = 60

Distribution Costs:
S1 β†’ Z1 = 4
S1 β†’ Z2 = 6
S1 β†’ Z3 = 8
S2 β†’ Z1 = 5
S2 β†’ Z2 = 4
S2 β†’ Z3 = 6
S3 β†’ Z1 = 7
S3 β†’ Z2 = 5
S3 β†’ Z3 = 3

Expected Output:
Optimal water distribution plan
Minimum total distribution cost

9. Footpath Connectivity Plan

Algorithm: Dijkstra + Bridge/Articulation detection (DFS)
Problem Content
Detect disconnected pedestrian networks, compute safe shortest routes, and suggest minimal new links to restore or improve connectivity.
Algorithmic Solution
Use DFS to find bridges/articulation points (fragile connections) and Dijkstra for safe shortest paths; recommend added edges using union-find / MST on candidate connections.
Input / Output (Project Version)
Input: pedestrian network graph. Output: bridges, articulation points, and suggested new links.
Related SDGs
SDG 11 β€” Sustainable Cities SDG 3 β€” Good Health

πŸ“· Click to View Image

C++ Example (Bridge detection)
// Bridge detection skeleton
#include <bits/stdc++.h>
using namespace std;
void dfs(int u,int p,const vector>& g,vector& tin,vector& low,vector& vis,int &timer,vector>& bridges){
  vis[u]=1; tin[u]=low[u]=++timer;
  for(int v: g[u]){
    if(v==p) continue;
    if(vis[v]) low[u]=min(low[u], tin[v]);
    else{
      dfs(v,u,g,tin,low,vis,timer,bridges);
      low[u]=min(low[u], low[v]);
      if(low[v] > tin[u]) bridges.push_back({u,v});
    }
  }
}
int main(){ int n,m; cin>>n>>m; vector> g(n); for(int i=0;i<m;i++){ int u,v; cin>>u>>v; g[u].push_back(v); g[v].push_back(u); }
  vector tin(n,-1), low(n,-1), vis(n,0); int timer=0; vector> bridges;
  for(int i=0;i<n;i++) if(!vis[i]) dfs(i,-1,g,tin,low,vis,timer,bridges);
  for(auto &b:bridges) cout << "Bridge: " << b.first << " - " << b.second << "\\n";
}
Emergency Units:
E1
E2

Service Areas:
Area A
Area B
Area C
Area D

Response Time (minutes):
E1 β†’ A = 5
E1 β†’ B = 7
E1 β†’ C = 6
E1 β†’ D = 8

E2 β†’ A = 6
E2 β†’ B = 4
E2 β†’ C = 5
E2 β†’ D = 7

Expected Output:
Assignment of emergency units to areas
Minimum maximum response time

10. Underground Utility Routing

Algorithm: A* / Dijkstra + Greedy Disjoint Routing
Problem Content
Plan multiple underground utility routes on a grid while avoiding conflicts, minimizing length and respecting obstacles.
Algorithmic Solution
Route utilities sequentially with A*/Dijkstra, mark used cells as blocked for subsequent routes, optionally iterate to improve disjointness.
Input / Output (Project Version)
Input: grid map and list of (start, goal) for each utility. Output: set of paths and cost metrics.
Related SDGs
SDG 9 β€” Industry & Infrastructure SDG 6 β€” Clean Water & Sanitation

πŸ“· Click to View Image

C++ Example (A* / Grid Dijkstra)
// A* / Dijkstra skeleton for grid pathfinding (mark path blocked and next)
#include <bits/stdc++.h>
using namespace std;
using pii = pair;
int heuristic(pii a, pii b){ return abs(a.first-b.first) + abs(a.second-b.second); }
int main(){
  ios::sync_with_stdio(false); cin.tie(nullptr);
  int R,C; cin>>R>>C; vector<string> grid(R);
  for(int i=0;i<R;i++) cin>>grid[i];
  int U; cin>>U; vector<pair<pii,pii>> req(U);
  for(int i=0;i<U;i++){ int sr,sc,gr,gc; cin>>sr>>sc>>gr>>gc; req[i]={{sr,sc},{gr,gc}}; }
  vector<vector(C,0));
  auto inb=[&](int r,int c){ return r>=0 && r<R && c>=0 && c<C; };
  int dr[4]={1,-1,0,0}, dc[4]={0,0,1,-1};
  for(int u=0;u<U;u++){
    auto [s,g] = req[u];
    priority_queue<tuple<int,int,int>, vector<tuple<int,int,int>>, greater<tuple<int,int,int>>> pq;
    vector<vector(C, INT_MAX)); vector<vector<pii>> parent(R, vector<pii>(C,{-1,-1}));
    dist[s.first][s.second]=0; pq.push({0,s.first,s.second});
    while(!pq.empty()){
      auto [d,r,c]=pq.top(); pq.pop();
      if(d!=dist[r][c]) continue;
      if(r==g.first && c==g.second) break;
      for(int k=0;k<4;k++){ int nr=r+dr[k], nc=c+dc[k]; if(!inb(nr,nc)) continue; if(grid[nr][nc]=='#') continue; if(blocked[nr][nc]) continue;
        if(dist[nr][nc] > d+1){ dist[nr][nc]=d+1; parent[nr][nc]={r,c}; pq.push({dist[nr][nc], nr, nc}); }
      }
    }
    if(dist[g.first][g.second]==INT_MAX){ cout << "Utility " << u << " cannot be routed\\n"; continue; }
    vector<pii> path; pii cur=g; while(!(cur==s)){ path.push_back(cur); cur=parent[cur.first][cur.second]; } path.push_back(s); reverse(path.begin(), path.end());
    for(auto &p:path) blocked[p.first][p.second]=1;
    cout << "Utility " << u << " routed length " << path.size()-1 << "\\n";
  }
  return 0;
}
Grid Map:
0 0 0 0 0
0 # # 0 0
0 0 0 0 0
0 # 0 # 0
0 0 0 0 0

Utilities:
Water  : Start (0,0) β†’ End (4,4)
Gas    : Start (0,4) β†’ End (4,0)
Electric: Start (2,0) β†’ End (2,4)

Legend:
0 = free cell
# = blocked cell

Expected Output:
Non-overlapping shortest paths for all utilities
Total routing cost minimized
← Back to Top
Β© 2025 Tejas Keri β€” Portfolio
Β© Contact : 01fe24bcs144@kletech.ac.in