Problem description error: ∆T = ⌈β2(h2 − h1)⌉ + γ, if h1 < h2 , here if we use γ as problem description,we get WA from online judge,so use δ here to get accepted. #include <iostream> #include <queue> #include <cstdio> #include <cstring> #include <cmath> #define INF 100000000 using namespace std; int M,N; int gr[20][20]; int dirx[4]={1,0,0,-1};
Category: Algorithm
589
#include <iostream> #include <string.h> #include <string> #include <vector> #include <map> #include <queue> #include <cstdio> #include <cstdlib> #define ll long long #define INF 100000000 using namespace std; struct INFO{ string str; int CNT; int BX; int BY; int SX; int SY; }; int MX; string input[25]; int tx,ty; int r,c; string path=""; const int dirx[4]={-1,0,0,1}; const
663
Idea: Find the total number of matching and then check for every match(left,right) pair whether it is unique or not. To check this find total number of matching using the same algorithm just excluding a pair each time and compare the total number of founded match with the initial one. If it is not reduced
1194
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <map> #include <vector> using namespace std; //int gr[105][105]; vector<int> gr[105]; int n,m,k; int rside[105],lside[105]; bool visit[105]; bool dfs(int pos) { for(int i=0;i<gr[pos].size();i++) { if(visit[gr[pos][i]]) continue; visit[gr[pos][i]] = 1; if(lside[gr[pos][i]]==-1 || dfs(lside[gr[pos][i]])) { rside[pos] = gr[pos][i]; lside[gr[pos][i]]= pos; return 1; } } return 0; } int main()
10080
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; int gr[105][105]; int N,M; double S,V; struct point{ double x; double y; }; point goph[105],hole[105]; // A DFS based recursive function that returns true if a // matching for vertex u is possible bool bpm(int u, bool seen[], int matchR[]) { // Try every
532
#include <iostream> #include <string.h> #include <vector> #include <cstdio> #include <queue> #define ll long long #define INF 100000000 using namespace std; int gr[32][32][32]; bool visit[32][32][32]; int dist[32][32][32]; int x,y,z; int ex,ey,ez; int L,R,C; void bfs() { int tmp_x,tmp_y,tmp_z; queue<int> q; q.push(x); q.push(y); q.push(z); visit[x][y][z]=1; dist[x][y][z] = 0; while(!q.empty()) { tmp_x = q.front(); q.pop(); tmp_y = q.front();
10364
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #define ll long long using namespace std; int sz[25]; ll sum; bool f; int total_piece; int stick_size; bool visit[25]; int M; bool cmp(int a,int b) { return a>b; } bool backtrack(int present_size,int index,int piece_cnt) { if(stick_size*piece_cnt==sum) return 1; for(int i=index;i<M;i++) { if(visit[i]) continue; if(i>0 && !visit[i-1] &&
307
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #define ll long long /* 9 5 2 1 5 2 1 5 2 1 4 1 2 3 4 38 2 6 6 8 7 4 1 8 4 1 4 4 3 3 2 3 3 4 6 8 8 7 2 4 1 1
622
#include <iostream> #include <string.h> #include <cstring> #include <vector> #include <cstdio> #include <stack> #include <queue> #include <algorithm> #define ll long long using namespace std; int error; string valu,res; int isOprtr(char c) { if(c=='+' || c=='-') return 1; if(c=='*' || c=='/' ||c=='%') return 2; return 0; } //1*(2+3*23+12*34)+3 = 482 //1*(2+3*23+12*34)+3*(4+5*65-13+8-2) = 1445 //2+3*(2+2-1+3+(12+12*3)+3+4) //1*2+3*23+12*34+3*4+5*65-13+8-2 //((20*((((((((100)))))))*100))) int
624
#include <iostream> #include <sstream> #include <string> #include <vector> #include <stack> #include <cstdio> #define INF 100000000 using namespace std; int arr[25]; int res[25]; int SZ; vector<int> vb; bool visit[25]; int ind; int MN; void backtrack(int remaining,int index) { if(remaining<MN) { MN = remaining; SZ = vb.size(); for(int i=0;i<SZ;i++) { res[i] = vb[i]; } } for(int i=index+1;i<ind;i++)