# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
647847 | 2022-10-04T08:57:02 Z | raresmihai | parentrises (BOI18_parentrises) | C++17 | 1 ms | 340 KB |
#include <iostream> #include <algorithm> #define MAXL 1000000 using namespace std; struct paranthesis{ bool type; int pos; }; int posOfOpen[MAXL], posOfOpenSize; paranthesis bad[MAXL + 2]; int badSize; char ans[MAXL]; int goodOpen[MAXL], goodOpenSize; int goodClosed[MAXL], goodClosedSize; int bs1(int val) { int st, dr, mij; st = -1; dr = goodClosedSize - 1; while ( dr - st > 1 ) { mij = (dr + st) / 2; if ( goodClosed[mij] < val ) st = mij; else dr = mij; } return dr; } int bs2(int val) { int st, dr, mij; st = 0; dr = goodOpenSize; while ( dr - st > 1 ) { mij = (st + dr) / 2; if ( goodOpen[mij] > val ) dr = mij; else st = mij; } return st; } int main() { int c, t, i, pos, lastPosOpen, lastPosClosed, n; char ch; bool good; scanf("%d", &c); if ( c == 1 ) { scanf("%d ", &t); while ( t-- ) { posOfOpenSize = goodClosedSize = goodOpenSize = 0; badSize = 1; ch = fgetc(stdin); i = 0; n = 0; while ( ch == '(' || ch == ')' ) { ans[i] = 'R'; if ( ch == '(' ) { posOfOpen[posOfOpenSize] = i; posOfOpenSize++; } else { if ( posOfOpenSize ) { posOfOpenSize--; goodOpen[goodOpenSize] = posOfOpen[posOfOpenSize]; goodOpenSize++; goodClosed[goodClosedSize] = i; goodClosedSize++; ans[i] = ans[posOfOpen[posOfOpenSize]] = 'R'; } else { bad[badSize].pos = i; bad[badSize].type = true; badSize++; } } i++; n++; ch = fgetc(stdin); } good = true; if ( good ) { for ( pos = 0; pos < n; pos++ ) { fputc(ans[pos], stdout); } printf("\n"); } else { printf("impossible\n"); } } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |