This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int MAX_N = 20; // Maximum dimensions for the 3D grid | |
char a[MAX_N][MAX_N][MAX_N]; // 3D grid matrix | |
bool vis[MAX_N][MAX_N][MAX_N]; // 3D visited matrix | |
int n, m, p; // Dimensions of the 3D grid | |
vector<tuple<int, int, int>> d = {{0,1,0},{0,-1,0},{-1,0,0},{1,0,0},{0,0,1},{0,0,-1}}; // 3D directions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
int main() { | |
int t;cin>>t; | |
while (t--) | |
{ | |
int n,sum=0;cin>>n; | |
vector<int>v(n-1); | |
for(int i=0;i<n-1;i++) |