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[100000]; 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 | Leave a comment

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 | Leave a comment

Poj Solution 1719

http://poj.org/problem?id=1719 #include <stdio.h> #include <memory.h> int e[1000][1000], en[1000], col[1000]; int match[1000]; bool sign1[1000], sign2[1000]; int flag[1000]; 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 | Leave a comment

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 | Leave a comment

Poj Solution 1715

http://poj.org/problem?id=1715 #include <stdio.h> #include <algorithm> using namespace std; char *digit = "FEDCBA9876543210"; //0123456789ABCDEF"; int p[8][8]; bool sign[16]; int main() { int i,j,n,k; char ans[9]; 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 | Leave a comment

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[600]; node *leaf[600]; int n, k; int e[600][3]; int v[600][3]; int d[600]; inline bool isleaf( node *s ) { return s->id … Continue reading

Posted in poj | Leave a comment

Poj Solution 1710

http://poj.org/problem?id=1710 #include<iostream> #include"memory.h" using namespace std; int n; bool map[101][101]; void init() {int i,j;bool k; k=1; for(i=1;i<=n;i++,k=!k) map[i][1]=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 | Leave a comment

Poj Solution 1709

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

Posted in poj | Leave a comment

Poj Solution 1708

http://poj.org/problem?id=1708 #include<iostream> #include"memory.h" using namespace std; int set[100][100]; int map[100][10000][2]; int path[100]; int n,l,k,q; int cir[100]; 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]++][1]; map[a][path[a]-1][0]=b;} } int queue[10000][3],head,tail; void find() {int a,b,c,i,to; head=0;tail=0; queue[tail][0]=l;queue[tail][1]=k; queue[tail][2]=0; set[l][k]=set[k][l]=1; … Continue reading

Posted in poj | Leave a comment