A terrain which has elevation differences is flooded with water. The water raises to some given level (elevation). This leaves some part of the terrain above water as well as some parts under water. So, it is quite possible that islands may form. You are supposed to count the islands and provide one coordinate per island that belongs to that island. It is possible to have lakes on an island but is assured that those lakes do not have further islands in them (so The “Van” lake is possible but the island of “Akdamar” is impossible). Furthermore you shall assume that somehow all waters secretly obey the Pascal principle (“Bile¸sik kaplar prensibi”).
PROBLEM
You will be given the terrain information as a 512 × 512 1 byte elevation matrix M. M[x][y] is holding the height of the point (x, y) (0 _ x, y < 512 and are integers). Furthermore 0 _ M[x][y] < 128 8x and 8y. You will also be given a height of water level W (0 < W < 128). You shall assume that any point of the terrain that has an a height that is smaller or equal to W is under water. You will determine how many islands are formed, output this count (n), and in addition to this output n many lines each having a coordinate of a point of one island. You have to provide one and only one coordinate per island. Which point you choose on an island is up to you. If a piece of terrain is partially (or fully) located (touching) at the edge(s) of the 512 × 512 grid, still it will count as an island. An island is the collection of terrain points, above water, from which you can find a path to any other without having to pass the path through water. A path is an ordered set of points where successive points have either their X coordinates the same and their Y coordinates different only by one in magnitude (so can be y − 1 or y + 1); or have their Y coordinates the same and have their X coordinates different only by one in magnitude (so can be x − 1 or x + 1). But not both of them: in other words they have to touch either in the X direction or in the Y direction, and not in the diagonal.
SPECIFICATIONS • The first line of the input contains a single integer, the W value. • From the following line (or lines) you will read 262144 (which is 512 × 512) integers of the matrix M in row order. You are advised to skip over all white spaces. • You are expected to output the count of islands n on the first line of the output. • Then, on each of the following n many lines there will be an x value followed by an y. Each line is a point on one of the islands. • There will be no error in the input, so you do not need to perform any error check. • There will be at most 100 islands. • You can allocate only one array in your program. Namely, a 512 × 512 char array.
• Dynamic memory allocation is forbidden. • The use of files throughout your program is forbidden
Bu soruyu türkçeye çevirdim daha anlaşılır olması için..
512 x 512 lik bi matris var ikili arraylarin olacak a[ ] [ ] biri i diğeri j matristeki her bir noktanın yüksekliği var bu da scanf le girdiğimiz char olacak bi de su seviyesi var onu da scanf le alacaz sonra bi kısmı suya batacak bi kısmı batmayacak batmayanlar ada eğer yanyana iki array batmamışsa ikisi birden tek ada böle büyük adalar olabiliyo outputta adaları söleyecez ama büyük adalardan sadece bir tek nokta söyleyecez yani tekli adayı aynen söylüyoz ama 10 lu ve ya başka çoklu adayı sadece içinden bir noktasını söylüyoz çoklu ada aşağıdan yukarıdan sağdan soldan bağlanabilir ama çapraz iki ada bir ada değildir çapraz bağlanmaz başka bi yolla mesela bi sağ bi aşağı olarak bağlanabilir bu kadar!!