# Monthly Archives: March 2011

## Poj Solution 1727

http://poj.org/problem?id=1727 #include "stdio.h" #include "algorithm" using namespace std; struct event{ int t, x; }p; bool cmp( event &a, event &b ) { return a.x+a.t < b.x+b.t; } int n, m; void input( ) { int i; scanf( "%d%d", &n, &m); … Continue reading

Posted in poj | Comments Off on Poj Solution 1727

## Poj Solution 1723

http://poj.org/problem?id=1723 import java.io.BufferedInputStream; import java.util.Arrays; import java.util.Scanner; public class Main { static int x[]; static int y[]; public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); if (scan.hasNext()) { int n = scan.nextInt(); x = new int[n]; … Continue reading

Posted in poj | Comments Off on Poj Solution 1723

## Poj Solution 1719

http://poj.org/problem?id=1719 #include <stdio.h> #include <memory.h> int e, en, col; int match; bool sign1, sign2; int flag; bool search( int a ) { int i, j; sign1[a] = true; for( i=0; i<en[a]; i++ ) { j = e[a][i]; if( !sign2[j] ) … Continue reading

Posted in poj | Comments Off on Poj Solution 1719

## Poj Solution 1716

http://poj.org/problem?id=1716 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int a=Integer.parseInt(in.readLine()); int ans=2,i; my[] arr=new my[a]; String[] ss; for(i=0;i< a;i++) { ss=in.readLine().split(" … Continue reading

Posted in poj | Comments Off on Poj Solution 1716

## Poj Solution 1715

http://poj.org/problem?id=1715 #include <stdio.h> #include <algorithm> using namespace std; char *digit = "FEDCBA9876543210"; //0123456789ABCDEF"; int p; bool sign; int main() { int i,j,n,k; char ans; for( k=0; k<8; k++ ) { p[k][7-k] = 1; for( i=6-k; i>=0; i– ) p[k][i] = … Continue reading

Posted in poj | Comments Off on Poj Solution 1715

## Poj Solution 1714

http://poj.org/problem?id=1714 #include <stdio.h> #include <algorithm> using namespace std; struct node { int id; int order; node *l,*r,*f; int lv,rv,fv; }tree; node *leaf; int n, k; int e; int v; int d; inline bool isleaf( node *s ) { return s->id … Continue reading

Posted in poj | Comments Off on Poj Solution 1714

## Poj Solution 1710

http://poj.org/problem?id=1710 #include<iostream> #include"memory.h" using namespace std; int n; bool map; void init() {int i,j;bool k; k=1; for(i=1;i<=n;i++,k=!k) map[i]=k; for(i=1;i<=n;i++) for(j=2;j<=n;j++) map[i][j]=!map[i][j-1]; } void doit() {int i,j,step=2*n+1;bool k=true; for(i=1;i<n;i++) {cout<<step; for(j=1;j<=n;j++) if(map[i][j]==k)cout<<‘ ‘<<(i-1)*n+j; cout<<endl; step+=2;k=!k; cout<<step; for(j=1;j<=n;j++) if(map[i][j]==k)cout<<‘ ‘<<(i-1)*n+j; cout<<endl; step+=2;k=!k; … Continue reading

Posted in poj | Comments Off on Poj Solution 1710

## Poj Solution 1709

http://poj.org/problem?id=1709 #include<iostream> #include"memory.h" #include"string.h" using namespace std; char word; int index; int n,l,len,set; void init() { int i; for(i=0;i<26;i++)index[i]=n; for(i=0;i<n;i++) { cin>>word[i]; len[i]=strlen(word[i]); if(index[word[i]-‘a’]==n)index[word[i]-‘a’]=i; } memset(set,1,1000*sizeof(int)); } char best;int go; char w; void find(int a,int b) { if(go&&strcmp(w,best)>0)return; if(b==a&&a) { … Continue reading

Posted in poj | Comments Off on Poj Solution 1709

## Poj Solution 1708

http://poj.org/problem?id=1708 #include<iostream> #include"memory.h" using namespace std; int set; int map; int path; int n,l,k,q; int cir; void init() {int i,m,a,b; memset(path,0,100*sizeof(int)); memset(set,0,100*100*sizeof(int)); cin>>n>>l>>k>>q; l–;k–;q–; for(i=0;i<n;i++)cin>>cir[i]; cin>>m; for(i=0;i<m;i++){cin>>a>>b;a–;b–; cin>>map[a][path[a]++]; map[a][path[a]-1]=b;} } int queue,head,tail; void find() {int a,b,c,i,to; head=0;tail=0; queue[tail]=l;queue[tail]=k; queue[tail]=0; set[l][k]=set[k][l]=1; … Continue reading

Posted in poj | Comments Off on Poj Solution 1708