| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 44388 | chonka | Pictionary (COCI18_pictionary) | C++98 | 687 ms | 27644 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std ;
#define MAXN 100007
int n , m , q ;
struct tuhla {
int x , y ;
int l , r ;
};
tuhla a[ MAXN ] ;
int prv[ MAXN ] ;
int ans[ MAXN ] ;
vector < int > v[ MAXN ] ;
int find ( int x ) {
if ( prv[ x ] == -1 ) { return x ; }
int y = find ( prv[ x ] ) ;
prv[ x ] = y ;
return y ;
}
void UNITE ( int x , int y ) {
int k1 = find ( x ) ;
int k2 = find ( y ) ;
if ( k1 != k2 ) {
prv[ k1 ] = k2 ;
}
}
void input ( ) {
scanf ( "%d%d%d" , &n , &m , &q ) ;
int i ;
for ( i = 1 ; i <= q ; i ++ ) {
scanf ( "%d%d" , &a[ i ].x , &a[ i ].y ) ;
a[ i ].l = 1 ;
a[ i ].r = m ;
}
}
void solve ( ) {
int i , j , t ;
for ( t = 1 ; t <= 20 ; t ++ ) {
for ( i = 1 ; i <= n ; i ++ ) { prv[ i ] = -1 ; }
for ( i = 1 ; i <= m ; i ++ ) { v[ i ].clear ( ) ; }
for ( i = 1 ; i <= q ; i ++ ) {
int mid = ( a[ i ].l + a[ i ].r ) / 2 ;
v[ mid ].push_back ( i ) ;
}
for ( i = 1 ; i <= m ; i ++ ) {
int step = ( m - i + 1 ) ;
for ( j = 2 * step ; j <= n ; j += step ) {
UNITE ( j - step , j ) ;
}
int sz = v[ i ].size ( ) ;
for ( j = 0 ; j < sz ; j ++ ) {
int id = v[ i ][ j ] ;
int k1 = find ( a[ id ].x ) ;
int k2 = find ( a[ id ].y ) ;
if ( k1 == k2 ) {
ans[ id ] = i ;
a[ id ].r = i - 1 ;
}
else {
a[ id ].l = i + 1 ;
}
}
}
}
for ( i = 1 ; i <= q ; i ++ ) {
printf ( "%d\n" , ans[ i ] ) ;
}
}
int main ( ) {
input ( ) ;
solve ( ) ;
return 0 ;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
