0% found this document useful (0 votes)
54 views9 pages

Disc

The document contains code for solving several coding problems. It includes code for checking if a given number is present in a 2D matrix and deleting the corresponding rows and columns, code for calculating exponent of fractions, and code for other problems involving strings, vectors, and sets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views9 pages

Disc

The document contains code for solving several coding problems. It includes code for checking if a given number is present in a 2D matrix and deleting the corresponding rows and columns, code for calculating exponent of fractions, and code for other problems involving strings, vectors, and sets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//MAXDIGITS//http://www.upcoder.xyz/'index.

php/
c0079be6a163a924976d1b198f3d3ddc10bf424876589716c2a8198072a7ccb4/
hzwqH''w4z_yRMoOMs!z5z'lBML4.skq'RwokBKpu's0hnmv'996'-.O7-.f:597-
CAg4:18MAM78cF_g9C8a'?iEA:_yC2E@Mu?C2m@M1?ph$OhxYRx5/
b074400d073a8acb1310cb8c6f6d71ff2e6cb8456a7346db3fc3f723cf5bbf65

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
int n;
cin >> n;
while (n--) {
string ai, bi;
cin >> ai >> bi;
int a, b;

if (ai.size() > 2)
a = int(ai[ai.size() - 1]) - '0';
else
a = stoi(ai);

if (bi.size() > 2)
b = (int(bi[bi.size() - 2]) - '0') * 10 + (int(bi[bi.size() - 1]) -
'0');
else
b = stoi(bi);

int a2[] = {6, 2, 4, 8};


int a3[] = {1, 3, 9, 7};
int a4[] = {6, 4, 6, 4};
int a7[] = {1, 7, 9, 3};
int a8[] = {6, 8, 4, 2};
int a9[] = {1, 9, 1, 9};

if (b == 0)
cout << 1 << endl;
else if (a == 0)
cout << 0 << endl;
else
switch (a % 10) {
case 5:
case 1:
case 0:
case 6:
cout << a % 10 << endl;
break;
case 2:
cout << a2[b % 4] << endl;
break;
case 3:
cout << a3[b % 4] << endl;
break;
case 4:
cout << a4[b % 4] << endl;
break;
case 7:
cout << a7[b % 4] << endl;
break;
case 8:
cout << a8[b % 4] << endl;
break;
case 9:
cout << a9[b % 4] << endl;
break;
}
}
return 0;
}

//SPY
NETWORK//http://www.upcoder.xyz/'index.php/04a919ff5b771b82055268fd97c3fb5bb19fcee9
39c3f8d5a53167bf2b8ee66e/hzwqH''w4z_yRMoOMs!
z5z'lBML4.skq'RwokBKpu's0hnmv'2966'KOaNEAMeNai569b-
796eiC82iEg67j3l5/462f38963bf77c2f012a4f28e8723c143295aaafc5cd893fe2cda3b4b9fd480c

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
int n, m, k;
cin >> n >> m >> k;

int a[1000][1000];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}

vector<int> rowsToDelete, colsToDelete;


for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i][j] == k) {
rowsToDelete.push_back(i);
colsToDelete.push_back(j);
}
}
}

sort(rowsToDelete.begin(), rowsToDelete.end());
sort(colsToDelete.begin(), colsToDelete.end());

if (rowsToDelete.size() == n && colsToDelete.size() == m) {


cout << "Null";
} else {
for (int i = 0; i < n; i++) {
if (binary_search(rowsToDelete.begin(), rowsToDelete.end(), i)) {
continue; // Skip this row
}
for (int j = 0; j < m; j++) {
if (binary_search(colsToDelete.begin(), colsToDelete.end(), j)) {
continue; // Skip this column
}
cout << a[i][j] << " ";
}
cout << endl;
}
}

return 0;
}

//BIRD//http://www.upcoder.xyz/'index.php/
6409cddba1c8582ff5bdfcb6a2a278e67e6703e08feef12e7f993c718ba5b42e/nwuTF''4zx!
wrcrLKv~4y7'jqKOx&SiT'rrrhmNBx'yxfpky'F_4~'-c9he~4_8~E8Me8596D~h:1i5f8.:6_-
6/15d703cfa010c37b75d36c9072bb453a16e518296e71a09e3da3dd50e635de00#include
<iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
int n;
cin >> n;

vector<int> birds(n);
for (int i = 0; i < n; ++i) {
cin >> birds[i];
}

int q;
cin >> q;

for (int i = 0; i < q; ++i) {


int shot;
cin >> shot;

birds.erase(birds.begin() + shot - 1);


}

for (int i = 0; i < birds.size(); ++i) {


cout << birds[i] << " ";
}
cout << endl;

return 0;
}

// pizza

#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <map>
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define WISH vector<pair<pair<char, int>, pair<char, int>>>
#define TASTE pair<char, int>
#define MAX 100010
#define f first
#define s second

using namespace std;

struct TASTES
{
char f;
int fs;
char s;
int ss;
};

void SORT(TASTE &f, TASTE &s)


{
if (f.s > s.s)
{
swap(f.f, s.f);
swap(f.s, s.s);
}
}
void CHECK(WISH pizza, int n, vector<int> &like, vector<int> &dislike, int t)
{
FOR(j, 0, n)
{
if (pizza[j].f.s == t)
{
if (pizza[j].f.f == '+')
{
like.push_back(j);
}
else
{
dislike.push_back(j);
}
}
}
}
bool IMP(WISH pizza, int n, vector<int> &like, vector<int> &dislike, int t)
{
bool res = false;

FOR(i, 0, like.size())
FOR(j, 0, dislike.size())
{
if (pizza[like[i]].s.s == pizza[dislike[j]].s.s)
{
if (pizza[like[i]].s.f != pizza[dislike[j]].s.f)
res = true;
}
}
return res;
}

void REP(WISH &pizza, int n, int m, vector<int> &like, vector<int> dislike,


vector<char> &result)
{
}

int main()
{

TASTES wish;
int n, m;

cin >> n >> m;


vector<char> result(m, ' ');
WISH pizza;
FOR(i, 0, n)
{
cin >> wish.f >> wish.fs >> wish.s >> wish.ss;
TASTE f(wish.f, wish.fs);
TASTE s(wish.s, wish.ss);
SORT(f, s);
pizza.push_back({f, s});
}
FOR(i, 0, m)
{
vector<int> like;
vector<int> dislike;
if (IMP(pizza, n, like, dislike, i) == true)
{
cout << "IMPOSSIBLE";
break;
}
else
{
if (like.size() > dislike.size())
{
result[i] = '+';
for (int it : like)
{
pizza.erase(pizza.begin() + it);
}
for (int it : dislike)
{
result[pizza[it].s.s] = pizza[it].s.f;
pizza.erase(pizza.begin() + it);
}
}
else
{
result[i] = '-';
for (int it : dislike)
{
pizza.erase(pizza.begin() + it);
}
for (int it : like)
{
result[pizza[it].s.s] = pizza[it].s.f;
pizza.erase(pizza.begin() + it);
}
}
}
}
for (auto it = result.begin(); it != result.end(); it++)
{
cout << *it;
}
}

//MINIGAME46.1:
NC1

#include <iostream>
#include <string>
#include <vector>
#include <set>
#define FOR(i,a,n) for (int i=a;i<n;i++)
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
set <string> res;
vector <string> str;
FOR(i,0,n)
{
string s;
cin>>s;
res.insert(s);
}
for (auto it=res.begin(); it != res.end(); ++it)
cout<<*it;

//pizza 2

#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <map>
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define WISH vector<pair<pair<char, int>, pair<char, int>>>
#define TASTE pair<char, int>
#define MAX 100010
#define f first
#define s second

using namespace std;


int CALL(int x, int i, vector<pair<int, int>> point)
{
if (x == point[i].f)
return point[i].s;
else
return point[i].s;
}

bool IMP(vector<vector<char>> pizza, vector <int> like, vector <int> dislike)


{
FOR(i,0,like.size())
{
FOR(j,0,dislike.size())
if(like[i])
}
}

int main()
{
int n, m;
cin >> n >> m;
vector<vector<char>> pizza(n, vector<char>(m, ' '));
vector<pair<int, int>> point;
vector<vector<int>> like(m);
vector<vector<int>> dislike(m);
FOR(i, 0, n)
{
int x, y;
char q, p;
cin >> q >> x >> p >> y;
pizza[i][x - 1] = q;
pizza[i][y - 1] = p;
if (q=='+')
like[x-1].push_back(i);
else dislike[x-1].push_back(i);
if(p=='-')
dislike[y-1].push_back(i);
else like[x-1].push_back(i);
point.push_back(make_pair(x-1, y-1));
}

///MINIGAME23.2:
EXPOFRAC
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
using namespace std;
long long UCLN(long long A, long long B) {
if (B == 0)
return A;
return UCLN(B, A%B);
}

int main()
{
int n;
cin>>n;
for (int i=0;i<n;i++)
{
long long a,b,m;
char s;
cin>>a>>s>>b>>m;
long long q=UCLN(b,a);
a=a/q;
b=b/q;
if(a==0)
cout<<0<<endl;
else if (m==0)
cout<<1<<endl;

else
{
if(m>0)
{
a=pow(a,m);
b=pow(b,m);
}
else
{
a=pow(a,-m);
b=pow(b,-m);
swap(a,b);
}
if (b==1)
cout<<a<<endl;
else if (b==-1)
cout<<-a<<endl;
else cout<<a<<"/"<<b<<endl;
}

return 0;
}

//DSK
#include <bits/stdc++.h>
using namespace std;

int main()
{
string str, str2;
cin >> str;
set<char> DSKT;
queue<char> DS, DS2;
int count = 0, tmp2 = 0;
char tmp;
for (auto x : str)
DSKT.insert(x);

for (auto a : DSKT)


{
int k = 0;
for (auto b : str)
if (a == b)
DS.push(b), k++;

if (k % 2 != 0)
tmp = a, tmp2 = k, count++;
else
str2.insert(str2.size() / 2, k, a);
if (count > 1)
{
cout << "NO SOLUTION";
return 0;
}
}

str2.insert(str2.size() / 2, tmp2, tmp);


cout << str2;
return 0;
}

You might also like