hihocoder:Lost in the City

时间限制:10000ms
单点时限:1000ms
内存限制:256MB
描述
Little Hi gets lost in the city. He does not know where he is. He does not know which direction is north.

Fortunately, Little Hi has a map of the city. The map can be considered as a grid of N*M blocks. Each block is numbered by a pair of integers. The block at the north-west corner is (1, 1) and the one at the south-east corner is (N, M). Each block is represented by a character, describing the construction on that block: ‘.’ for empty area, ‘P’ for parks, ‘H’ for houses, ‘S’ for streets, ‘M’ for malls, ‘G’ for government buildings, ‘T’ for trees and etc.

Given the blocks of 3*3 area that surrounding Little Hi(Little Hi is at the middle block of the 3*3 area), please find out the position of him. Note that Little Hi is disoriented, the upper side of the surrounding area may be actually north side, south side, east side or west side.

输入
Line 1: two integers, N and M(3 <= N, M <= 200).
Line 2~N+1: each line contains M characters, describing the city’s map. The characters can only be ‘A’-‘Z’ or ‘.’.
Line N+2~N+4: each line 3 characters, describing the area surrounding Little Hi.

输出
Line 1~K: each line contains 2 integers X and Y, indicating that block (X, Y) may be Little Hi’s position. If there are multiple possible blocks, output them from north to south, west to east.

样例输入


import java.util.*;

public class Main {

    static HashSet<Postion> retList = new HashSet<Main.Postion>();

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int m = cin.nextInt();
        ArrayList<String> map = new ArrayList<String>();
        ArrayList<String> me = new ArrayList<String>();
        for (int i = 0; i < n; ++i) {
            map.add(cin.next());
        }
        me.add(cin.next());
        me.add(cin.next());
        me.add(cin.next());
        for (int i = 0; i < 4; ++i) {
            getPosition(map, me);
            me = transfer(me);
            // output(me);
        }
        if (retList.size() > 0) {
            Postion[] ps = new Postion[retList.size()];
            retList.toArray(ps);
            Arrays.sort(ps, new Comparator<Postion>() {
                public int compare(Postion o1, Postion o2) {
                    return o1.i != o2.i ? o1.i - o2.i : o1.j - o2.j;
                }
            });
            for (Postion p : ps) {
                System.out.println(p.i + " " + p.j);
            }
        }

    }

    static class Postion {
        int i;
        int j;

        public Postion(int i, int j) {
            this.i = i;
            this.j = j;
        }

        /*
         * public int compareTo(Postion o) { return i != o.i ? i - o.i : j -
         * o.j; }
         */
        public boolean equals(Object o) {
            if (o instanceof Postion) {
                Postion o2 = (Postion) o;
                Postion o1 = this;
                return o1.i == o2.i && o1.j == o2.j;
            }
            return false;
        }

        public int hashCode() {
            return (i << 4) + j;
        }
    }

    static void output(ArrayList<String> list) {
        for (String s : list) {
            System.out.println(s);
        }
    }

    static ArrayList<String> transfer(ArrayList<String> me) {
        ArrayList<String> ret = new ArrayList<String>();
        byte[][] a = new byte[3][3];

        for (int i = 0; i < 3; ++i) {
            byte[] t = me.get(i).getBytes();
            for (int j = 0; j < 3; ++j) {
                a[j][2 - i] = t[j];
            }
        }
        for (int i = 0; i < 3; ++i) {
            ret.add(new String(a[i]));
        }
        return ret;
    }

    static int[] getPosition(ArrayList<String> map, ArrayList<String> me) {
        for (int i = 0, len = map.size() - 2; i < len; ++i) {
            String line = map.get(i);
            int index = 0;
            while (line.indexOf(me.get(0), index) != -1) {
                if (map.get(i + 1).indexOf(me.get(1), index) == line.indexOf(me.get(0), index)
                        && map.get(i + 2).indexOf(me.get(2), index) == line.indexOf(me.get(0), index)) {
                    retList.add(new Postion(i + 2, line.indexOf(me.get(0), index) + 2));
                }
                index++;
            }
        }
        return null;
    }
}


/*

9 9
asdasdasd
asdasdasd
asdasdasd
asdasdasd
asdasdasd
asdasdasd
asdasdasd
asdasdasd
asdasdasd
asd
asd
asd

*/
回答: ORA-12547: TNS:lost contact是一个Oracle数据库连接错误。它表示在尝试与数据库建立连接时,客户端无法与数据库服务器建立有效的通信。这可能是由于网络问题、数据库服务器故障或配置错误引起的。\[1\] 要解决ORA-12547错误,可以尝试以下几个步骤: 1. 检查网络连接:确保客户端和数据库服务器之间的网络连接正常,并且没有任何阻塞或防火墙问题。 2. 检查监听器状态:使用lsnrctl命令检查监听器的状态,确保监听器正在运行并且没有任何错误。\[3\] 3. 检查数据库服务:确保数据库服务正在运行,并且监听器配置文件(listener.ora)中正确地定义了服务。\[3\] 4. 检查TNS名称解析:确保客户端的TNS名称解析文件(tnsnames.ora)中正确地定义了数据库的连接信息。 5. 检查客户端配置:确保客户端的Oracle客户端软件正确安装,并且配置文件(sqlnet.ora)中没有任何错误或冲突。 如果以上步骤都没有解决问题,可以尝试重新启动数据库服务器或联系数据库管理员进行进一步的故障排除。\[2\] 总结: ORA-12547: TNS:lost contact是一个Oracle数据库连接错误,可能由于网络问题、数据库服务器故障或配置错误引起。要解决此错误,可以检查网络连接、监听器状态、数据库服务、TNS名称解析和客户端配置,并采取相应的措施。如果问题仍然存在,可以尝试重新启动数据库服务器或联系数据库管理员进行进一步的故障排除。 #### 引用[.reference_title] - *1* [造成错误“ORA-12547: TNS:lost contact”的常见原因有哪些?](https://blog.youkuaiyun.com/susscloud/article/details/123031130)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [ORA-12547: TNS:lost contact 问题处理](https://blog.youkuaiyun.com/qq_24699007/article/details/121284551)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值