#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n; char s[26]; while (scanf("%d",&n)==1) { if (!n) return 0; int max_x=0; int total_x=0; getchar(); for (int i=0;i<n;i++) {
Wednesday, October 5, 2016
Friday, September 23, 2016
UVA 10101 - Bangla Numbers Solution
#include<cstdio> #include<cstring> using namespace std; int main() { long long int tc=0,n; while (scanf("%lld",&n)!=EOF) { printf("%4lld.",++tc); if (n==0){ printf(" 0\n"); continue;} int a[20]={0},i=14; while (n) { a[i--]=n%10; n/=10; }
UVA 11503 - Virtual Friends Solution
#include<iostream> #include<cstdio> #include<string> #include<vector> #include<map> #include<algorithm> using namespace std; class DS{ private: vector<int>parent,rank,setSize; int numSets; public: DS(int n) { numSets=n; parent.assign(n,0); rank.assign(n,0); setSize.assign(n,1); for (int i=0;i<n;i++) parent[i]=i; } int
Tuesday, September 20, 2016
Codeforces 716A Solution
#include<bits/stdc++.h> using namespace std; int main() { int n,c; scanf("%d%d",&n,&c); int ans=0; int d=0; while (n--) { int t; scanf("%d",&t); if (t-d>c) ans=1; else ans++; d=t; } printf("%d\n",ans); return
Wednesday, August 24, 2016
UVA 10009 - All Roads Lead Where - Solution
#include<bits/stdc++.h> using namespace std; #define pb push_back class Graph{ int V; list<int>*adj; public: Graph(int V){this->V=V; adj=new list<int>[V]; } ~Graph() {delete []adj;} void addEdge(int u,int v){adj[u].pb(v); adj[v].pb(u); } void BFS(int
UVA 924 - Spreading The News- Solution
#include<bits/stdc++.h> using namespace std; #define pb push_back class Graph{ int V; list<int>*adj; public: Graph(int V){this->V=V; adj=new list<int>[V];} ~Graph(){delete []adj;} void addEdge(int u,int v){ adj[u].pb(v);} void BFS(int s) { if
UVA 762 - We Ship Cheap -Solution
#include<bits/stdc++.h> using namespace std; #define pb push_back map<string,int>msi; map<int,string>mis; class Graph{ int V; list<int>*adj; public: Graph(int V){this->V=V; adj=new list<int>[V]; } ~Graph() {delete []adj;} void addEdge(int u,int v){adj[u].pb(v); adj[v].pb(u); }
UVA 627 - The Net -Solution
#include<bits/stdc++.h> using namespace std; #define pb push_back class Graph{ int V; list<int>*adj; public: Graph(int V); ~Graph(); void addEdge(int u, int v); void BFS(int s,int dest); }; Graph::Graph(int V) //construtor
Subscribe to:
Posts (Atom)