Show all threads Hide all threads Show all messages Hide all messages |
If you can tell me the HINT<><>><<>><<><<< | Levan Kasradze (GEO) | 1006. Square Frames | 24 Sep 2023 13:51 | 2 |
tell me the hint, i want to solve this problem. Always extract squares that you know can be valid to extract at that point in time. Also, another hint, even if you extract a square, you could reuse its grid to extract other squares, and the characters under the extracted square's grid can be anything you want them to be. |
For anyone struggling to read the input | mihai.alpha | 1006. Square Frames | 24 Sep 2023 02:16 | 1 |
First off in your text editor switch from utf8 to cp437 (for example I use vscode and there's a tab in the bottom left that I can click to change the encoding). Only then, go to another comment on this problem (template for msvs 2010) and copy-paste the table from there. |
Some tests | Tunez(ITMO) | 1006. Square Frames | 14 Jan 2023 23:39 | 2 |
.................................................. .......................┌──────┐................... .......................│......│................... .......................│......│................... .......................│......│................... .......................│......│................... .......................│......│................... ┌────────┐.............│......│................... │........│.............└──────┘................... │........│........................................ │........│........................................ │─────┐..│........................................ │.....│..│........................................ │.....│..│........................................ │.....│..│..............┌──┐...................... │.....│..│..............│..│...................... └────────┘..............│..│...................... └─────┘.................└──┘...................... .................................................. .................................................. .................................┌┐............... .................................└┘............... ..┌──────┐.................................┌─────┐ ..│......│........┌────────┐...............│.....│ ..│......│........│........│...............│.....│ ..│......│........│........│...┌───┐.......│.....│ ..│.┌───┐│........│........│...│...│.......│.....│ ..│.│┌──││───┐....│........│..┌│──┐│.......│.....│ ..│.││..││...│....│........│..││..││.......└─────┘ .┌└─│───│┘┐..│....│........│..┌─┐──┘.............. .┌──└───┘.│..│....│........│..│.│.│............... .│...││...│..│┌─────┐......│..└─┘─┘............... .│...││...│..││...└─│──────┘...┌───┐.............. .│...││...│..││.....│..........│...│.............. .│...││...│..││.....│..........│...│.............. .└────┘──────┘│.....│........┌───┐.│.............. .│........│...│.....│........│.└─│─┘.............. .│........│...└─────┘........│..┌│................ .└────────┘..................│..└│................ .............................└───┘................ .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ..........┌─┐─┌─┐................................. ..........│.│.│.│................................. ..........┌─────┐................................. ..........│.....│................................. ..........│.....│................................. ..........│.....│.....................┌┌┐......... ..........│.....│.....................┌┐┐......... ..........│.....│.....................└┘┘......... ..........└─────┘................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ..┌┐.............................................. ..└┌┐┌┐........................................... ...└┌└┘........................................... ....└┘............................................ .................................................. .................................................. ...............................┌┌┌┐┐┐............. ...............................└└└┘┘┘............. .....┌───┐........................................ .....│┘─└│........................................ .....││.││........................................ .....│┐─┌│........................................ .....└───┘........................................ .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ┌┌──┌┌──┐────┐┐───┌┐─┌───────┐─┌─────┌──┐┐───┌───┐ ┌│──│││││─│──│──┌─────────┐───┐┌────┐─┐┌││┐││││┐┐│ │││││││┌│────│──┌────┐─┘──││││││┌─────────┐──││──│ ││┌┌│└──┘─│─┌│┐─││││││││││││┌─│││││─││││┘│││─││─││ │┌──┌──┐──┘─┌───│──┐─│─┐──│┌───││┐│┐│─│───│┌─────┐ └│──││││││┌─│││─││┐│─│┐│└┌││──┘│││──││││││││──┘│││ └│──│──││─│┌────│──┐││││┌┐│││┌─└│───┘│││┌─││─────│ ┌│││└──┘┌─└│││──└────┘││└┘│││││┌││└─│─│┘│─││────┘│ ┌│┐││─┐│││││││││││││┌─┐│──││─│││││─┐││││││││││││││ │││─└──────││┘│┌│││││─││─┌││└│└─││──│─┘│││││─┐│┘││ └└─────││││││─│└││││└─┘│──│└────│┘││││─││┘│└─────┘ │││││││││─││└──────│──────┘└─│──│──┌│───┌──────┐─│ └─┘┌│┌─└│──│─────┌─│──┐│───┘┌└─┌└───────│─┘│┘│││││ ││└││││││└└│──┐──│─│──│┘─│└──│─│││││││─│││││─┌││─┐ ││┌─│┌──│─┐└───────┘││││││─│││┌│┐│││││││││││─└││││ ┌──┐││┘││││││─┌┐││─│││││┌┐─││││││││││──┘││───│││─│ ││└│└───└──└──└┘─│─└──││└┘──││└│┘│││││─┘│└────┘│││ │└└│─│┘─│││││──││└────┘│─┘─││└─└───└────│──┘┌└─│─┘ └──┘─│└─││││└───│──│──┘│────│─┘│─└─┘──┘─└──────┘─┘ └────└────┘└────└──────┘────└──────┘┘┘───└┘─┘─┘┘└┘ Edited by author 08.09.2019 16:59 Edited by author 08.09.2019 17:01 Edited by author 08.09.2019 17:01 Edited by author 08.09.2019 17:06 Edited by author 08.09.2019 17:06 Edited by author 08.09.2019 17:07 Edited by author 08.09.2019 17:07 Edited by author 08.09.2019 17:15 Wow! The last one is not with 15 square frames, but you did a great job! Thanx! |
Author could use L, r, /, \ for corners instead of pseudographics :) | Harkonnen | 1006. Square Frames | 11 Aug 2022 11:56 | 1 |
|
For reading input in c# | ₰ҟᾷѓßὂνṑγ (ONPU) | 1006. Square Frames | 5 Jun 2022 14:12 | 1 |
... TextReader reader = new StreamReader(Console.OpenStandardInput(), System.Text.Encoding.GetEncoding("iso-8859-1")); ... string line = reader.ReadLine(); ... |
To admins (and python coders) | yyll | 1006. Square Frames | 23 Jun 2021 20:48 | 2 |
I don't know why, but in Python, code points of frame characters are: upper_left = 1066 upper_right = 1111 lower_left = 1040 lower_right = 1065 horizontal = 1044 vertical = 1110 That's really strange, because there are no common codecs encode those characters as such. Could Admin fix this or at lease give some explanations please? Also, don't put non-ascii characters in your source code, but use: c == chr(1066) or ord(c) == 1066 ord('┌') == 9484 list('┌'.encode('cp437')) == [218] list('┌'.encode('utf_16_le')) == [12, 37] # 12+37*256 == 9484 and Unicode code point is: U+250C == 9484 |
Tips for the question | Myrcella | 1006. Square Frames | 21 Aug 2018 07:51 | 1 |
This problem bothered me a lot. So I decide to write something about it to help other people to solve it more quickly. --------------------------------------------- 1.unsigned char or getchar()(which returns int) must be used to deal with the input --------------------------------------------- 2.When you're testing the program you write, maybe you will find that your PC can't run correct answer(even your code is right)(at least on my local PC... My accepted code always output 0 be cause char such as ┌ is always regarded as two char(s?). So here is how I check my program. ---------------------------------------------------------- This is the original sample: .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........┌─────┐................................ ...........│.....│................................ ....┌──────│.....│..........┌─┐................... ....│......│.....│..........│.│................... ....│......│.....│..........└─┘................... ....│......│....┌│────┐.............┌─┐........... ....│......└─────┘....│.............│.│........... ....│......│....│.....│.............└─┘........... ....│......│....│.....│.........┌──┐.............. ....└──────┘....│.....│.........│..│.............. ................│.....│.........│..│.............. ................└─────┘.........└──┘.............. .................................................. .................................................. And I changed it to the figure below: .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........+,,,,,+................................ ...........*.....*................................ ....+,,,,,,*.....*..........+,+................... ....*......*.....*..........*.*................... ....*......*.....*..........+,+................... ....*......*....+*,,,,+.............+,+........... ....*......+,,,,,+....*.............*.*........... ....*......*....*.....*.............+,+........... ....*......*....*.....*.........+,,+.............. ....+,,,,,,+....*.....*.........*..*.............. ................*.....*.........*..*.............. ................+,,,,,+.........+,,+.............. .................................................. .................................................. In this case my local PC gave the right answer. You just need a little change to make it work (i.e. change the ascii) |
How to read the input? | Myrcella | 1006. Square Frames | 20 Aug 2018 21:08 | 4 |
I found that my program could't deal with ┌┐└┘ correctly. A sample of input is wanted. Please help. Thanks in advance. I haven't solved this problem yet. The table that you see right after "The frame consists of the following characters:" statement tells you how you should read these special characters. I tried to generate the sample input, but not sure if it is correct since these are unprintable characters (atleast with my local PC encoding) and I cannot really verify it. Nevertheless, here is my attempt to generate it. It looks rugged, but that is because of encoding issues. You should probably output it on your own PC with the program below. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........ÚÄÄÄÄÄ¿................................ ...........³.....³................................ ....ÚÄÄÄÄÄij.....³..........ÚÄ¿................... ....³......³.....³..........³.³................... ....³......³.....³..........ÀÄÙ................... ....³......³....Ú³ÄÄÄÄ¿.............ÚÄ¿........... ....³......ÀÄÄÄÄÄÙ....³.............³.³........... ....³......³....³.....³.............ÀÄÙ........... ....³......³....³.....³.........ÚÄÄ¿.............. ....ÀÄÄÄÄÄÄÙ....³.....³.........³..³.............. ................³.....³.........³..³.............. ................ÀÄÄÄÄÄÙ.........ÀÄÄÙ.............. .................................................. .................................................. and the program that output it. It reads squares as in output sample and draws a board. struct square { int x, y, a; square() = default; square(int x, int y, int a) : x(x), y(y), a(a) {} }; void solve(std::istream &in, std::ostream &out) { std::vector<square> squares; int n; in >> n; for (int i = 0; i < n; ++i) { int x, y, a; in >> x >> y >> a; squares.emplace_back(x, y, a); } unsigned char board[20][50]; for (int i = 0; i < 20; ++i) { for (int j = 0; j < 50; ++j) { board[i][j] = '.'; } } for (square sq : squares) { board[sq.y][sq.x] = 218; // top-left board[sq.y][sq.x + sq.a - 1] = 191; // top-right board[sq.y + sq.a - 1][sq.x] = 192; // bottom-left board[sq.y + sq.a - 1][sq.x + sq.a - 1] = 217; // bottom-right for (int x = sq.x + 1; x < sq.x + sq.a - 1; ++x) { board[sq.y][x] = 196; // top edge board[sq.y + sq.a - 1][x] = 196; // bottom edge } for (int y = sq.y + 1; y < sq.y + sq.a - 1; ++y) { board[y][sq.x] = 179; // left edge board[y][sq.x + sq.a - 1] = 179; // right edge } } for (int i = 0; i < 20; ++i) { for (int j = 0; j < 50; ++j) { out << board[i][j]; } out << '\n'; } } int main() { solve(std::cin, std::cout); } As for reading it. I think you used char, while you need unsigned char or int for this problem. You can use getchar() that returns int or read into unsigned char s[SIZE]
Edited by author 20.08.2018 20:13 Edited by author 20.08.2018 20:13 Edited by author 20.08.2018 20:13 Edited by author 20.08.2018 20:19 Edited by author 20.08.2018 20:26 Edited by author 20.08.2018 20:34 Thank you for such long explaination! I will try it again. The problem is solved successfully. Thank you very much! |
What does "the length of the frame side" mean? | Myrcella | 1006. Square Frames | 20 Aug 2018 19:40 | 7 |
I don't understand it well... As the frame defined by the tripple (X, Y, A) will have such vertices: (X, Y) (X, Y + A - 1) (X + A - 1, Y) (X + A - 1, Y + A - 1) Thank you (for answer my question again)!8D The figure given is very "ugly" so that I didn't realize that it's a square! Edited by author 20.08.2018 17:33 (Maybe we can make a friend OvO. My codeforces id is the same as my id here. Thank you for your kind suggestion, but I am not a big fan of such things. Could you answer my another question please? How to read the input?(The problem has been posted) This has really bothered me a lot... |
"Length of the frame side" in output | e05 | 1006. Square Frames | 20 Aug 2018 09:07 | 3 |
Is it height or width of frame? Edited by author 27.05.2015 16:11 |
В благодарность разработчикам | Dubsage | 1006. Square Frames | 8 Feb 2016 03:36 | 1 |
Очень понравилась задача. Но не хватает сильных тестов. Хочется посоревноваться с другими людьми. +) А так оптимизируй,не оптимизируй - всё равно одна миллисекунда. И всё таки. Задача отличная. Спасибо. Edited by author 08.02.2016 03:37 |
How i can enter input. | Valery | 1006. Square Frames | 28 Apr 2015 07:05 | 7 |
please help me. I write program,but I can not test it, because I dont know how to enter a test. for i := 1 to n do readln(s[i]); use standart windows notepad when you press CTRL you can can use numpad to enter ASCII Codes of symbols open notepad: press ALT press 2 on numpad (digit keyboard on rigth side of keyboard) press 1 press 8 release ALT and you see Edited by author 15.09.2007 00:29 This is the sample input:(just copy it and look it in DOS) .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........谀哪哪?............................... ...........?....?............................... ....谀哪哪某.....?.........谀?.................. ....?.....?....?.........??.................. ....?.....?....?.........滥?.................. ....?.....?...诔哪哪?............谀?.......... ....?.....滥哪哪?...?............??.......... ....?.....?...?....?............滥?.......... ....?.....?...?....?........谀目.............. ....滥哪哪馁....?....?........?.?............. ................?....?........?.?............. ................滥哪哪?........滥馁.............. .................................................. .................................................. Edited by author 08.12.2007 17:30 Edited by author 08.12.2007 17:30 by the way you can use font "lucida console" or "terminal" I use #ifndef ONLINE_JUDGE in C and read the input in the same format as the output should look like, then draw the squares with C code in my program - makes testing much easier. Set you console encoding 1252 before input(c++ : system("chcp 1252");) Copy past below. Do not change encoding of browser (it should be UTF-8), other way it convert to 2 byte sequence. You can try to copy this to standard windows notepad. If using Notepad++, set encoding to UTF8 before paste. Should work. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........ÚÄÄÄÄÄ¿................................ ...........³.....³................................ ....ÚÄÄÄÄÄij.....³..........ÚÄ¿................... ....³......³.....³..........³.³................... ....³......³.....³..........ÀÄÙ................... ....³......³....Ú³ÄÄÄÄ¿.............ÚÄ¿........... ....³......ÀÄÄÄÄÄÙ....³.............³.³........... ....³......³....³.....³.............ÀÄÙ........... ....³......³....³.....³.........ÚÄÄ¿.............. ....ÀÄÄÄÄÄÄÙ....³.....³.........³..³.............. ................³.....³.........³..³.............. ................ÀÄÄÄÄÄÙ.........ÀÄÄÙ.............. .................................................. .................................................. Additional input: .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........ÚÄÄÄÄÄ¿................................ ...........³.....³................................ ....ÚÄÄÄÄÄij.....³......ÚÄ¿ÄÚÄ¿................... ....³......³.....³......³.³.³.³................... ....³......³.....³......ÀÄÙÄÀÄÙ................... ....³......³....Ú³ÄÄÄÄ¿.............ÚÄ¿........... ....³......ÀÄÄÄÄÄÙ....³.............³.³........... ....³......³....³.....³.............ÀÄÙ........... ....³......³....³.....³.........ÚÄÄ¿.............. ....ÀÄÄÄÄÄÄÙ....³.....³.........³..³.............. ................³.....³.........³..³.............. ................ÀÄÄÄÄÄÙ.........ÀÄÄÙ.............. .................................................. .................................................. Edited by author 28.04.2015 07:40 |
read input in python | crc | 1006. Square Frames | 25 Jan 2015 02:56 | 1 |
Hi, I get runtime error with my program. I am almost sure that it is some problem with reading the input. I have tested my program with many examples and always get the right answer. This is what I use to read the input: for y,line in enumerate(stdin.read().split()): for x,char in enumerate(line.decode('utf8')): c=ord(char) ....... I had to use decode('utf8') otherwise I got some strange characters. But now the number I get from ord(char) are not the codes given in the problem. Thanks. |
Template for MSVS 2010 | Ivan Tyamgin (TNU) | 1006. Square Frames | 27 May 2014 23:01 | 1 |
#define ┌ 218 #define ┘ 217 #define └ 192 #define ┐ 191 #define ─ 196 #define │ 179 #define N 20 #define M 50 unsigned char A[N][M + 1]; int main() { int i, j; for (i = 0; i < N; i++) { for (j = 0; j < M; j++) A[i][j] = getchar(); if (getchar() != '\n') throw 1; } } /* .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........┌─────┐................................ ...........│.....│................................ ....┌──────│.....│..........┌─┐................... ....│......│.....│..........│.│................... ....│......│.....│..........└─┘................... ....│......│....┌│────┐.............┌─┐........... ....│......└─────┘....│.............│.│........... ....│......│....│.....│.............└─┘........... ....│......│....│.....│.........┌──┐.............. ....└──────┘....│.....│.........│..│.............. ................│.....│.........│..│.............. ................└─────┘.........└──┘.............. .................................................. .................................................. */ Edited by author 27.05.2014 23:01 |
To C++ programmer, use UNSIGNED CHAR instead of CHAR | Phan Hoài Nam - Đại học Ngoại ngữ Tin Học TP.HCM | 1006. Square Frames | 17 Jun 2013 00:26 | 3 |
Edited by author 16.07.2010 13:34 |
Why 11 6 2 is not an answer? | LampLight | 1006. Square Frames | 26 Feb 2013 19:55 | 3 |
11 6 2 is also a possible frame.... Yes, you might add this frame to the output, and it would remain correct. |
is order important ? | Aneto | 1006. Square Frames | 26 Feb 2013 19:54 | 2 |
It isn't. You have certain freedom in the order, as stated: "You need to write a program that builds a possible sequence of frames that (if drawn sequentially) would produce the same picture on the screen. Your sequence does not have to be the same with the original sequence used to build the picture on the screen." |
Weak tests! | tyomitch | 1006. Square Frames | 26 Feb 2013 19:52 | 1 |
My AC solution fails whenever the left and right sides of a frame are both obscured. E.g.: .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........┌─────┐................................ ...........│.....│................................ ....┌──────│.....│..........┌─┐................... ....│......│.....│..........│.│................... ....│......│...┌┐│..........└─┘................... ....│......│...└┘│────┌─────┐.......┌─┐........... ....│......└─────┘....│.....│.......│.│........... ....│......│....┌───┐.│.....│.......└─┘........... ....│......│....│...│.│.....│...┌──┐.............. ....└──────┘....│...│.│.....│...│..│.............. ................│...│.│.....│...│..│.............. ................└───┘─└─────┘...└──┘.............. .................................................. .................................................. |
A little prog that may help you during a debug | tiancaihb | 1006. Square Frames | 25 Feb 2013 20:31 | 2 |
For all the copypaste aficionados: the sample given is .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ...........┌─────┐................................ ...........│.....│................................ ....┌──────│.....│..........┌─┐................... ....│......│.....│..........│.│................... ....│......│.....│..........└─┘................... ....│......│....┌│────┐.............┌─┐........... ....│......└─────┘....│.............│.│........... ....│......│....│.....│.............└─┘........... ....│......│....│.....│.........┌──┐.............. ....└──────┘....│.....│.........│..│.............. ................│.....│.........│..│.............. ................└─────┘.........└──┘.............. .................................................. .................................................. |
I don't know how read input | Yuri.Pechatnov | 1006. Square Frames | 14 Aug 2011 16:59 | 1 |
I use Ubuntu 9.10, Codeblocks 8.02 Или более понятно по-русски: я не представляю как считать спецсимволы :/ их коды у меня получаются рандомные в зависимости от кодировки но только не те что надо.. |