회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
1
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
테케는 맞게 나오는데 제출만 하면 틀렸다고 나옵니다 ㅠㅠ
17822번 - 원판 돌리기
zelot11
4년 전
0
혹시 반례나 어디가 잘 못 되었는지 알 수 있을까용??
#include <iostream> int N, M, T; int map[50][50]; int action[50][3]; using namespace std; void cw(int index, int distance) { int temp[50]; for( int e=0; e<M; e++) { temp[e]=map[index][e]; } for( int k=0; k<M-distance; k++) { map[index][k+distance]=temp[k]; } for( int k=0; k<distance; k++) { map[index][k]=temp[M-distance+k]; } return; } void ccw(int index, int distance) { int temp[50]; for(int e=0; e<M; e++) { temp[e]=map[index][e]; } for( int k=0; k<distance; k++) { map[index][k-distance+M]=temp[k]; } for( int k=0; k<M-distance; k++) { map[index][k]=temp[distance+k]; } return; } int check() { int copymap[50][50]={0}; for( int y=0; y<N; y++) { for( int x=0; x<M; x++) { int xleft=x-1; int xright=x+1; if( (x-1)<0) xleft=M-1; if( (x+1)==M ) xright=0; if (map[y][x]==map[y][xleft]&& !(map[y][x]==0)) { copymap[y][x]=1; copymap[y][xleft]=1; } if ( map[y][x]==map[y][xright]&& !(map[y][x]==0)) { copymap[y][x]=1; copymap[y][xright]=1; } } } if( N==2) { for( int x=0; x<M; x++) { if( map[1][x]==map[0][x]&& (!map[0][x]==0)) {copymap[1][x]=1;copymap[0][x]=1;} } } else { for( int y=1; y<N-1; y++) { for( int x=0; x<M; x++) { if( map[y][x]==map[y-1][x]&& (!map[y][x]==0)) {copymap[y][x]=1;copymap[y-1][x]=1;} if( map[y][x]==map[y+1][x]&&(!map[y][x]==0)) {copymap[y][x]=1;copymap[y+1][x]=1;} } } } int count1=0; for( int y=0; y<N; y++) { for( int x=0; x<M; x++) { if( copymap[y][x]==1 ) { map[y][x]=0; count1=1; } } } // cout<<"real"<<count1<<endl; return count1; } int main() { cin>>N>>M>>T; for (int y=0; y<N; y++) { for( int x=0; x<M; x++) { cin>> map[y][x]; } } for( int k=0; k<T; k++) { for( int z=0; z<3; z++) { cin>> action[k][z]; } } for( int e=0; e<T; e++) { int bae= action[e][0]; int rotation=action[e][1]; int dist= action[e][2]; for( int w=0; w<(M/bae) ; w++) { int q=bae+bae*w-1; // cout<<"ddd"<<q+1<<endl; if( rotation==0) { cw(q,dist ); } else { ccw(q,dist ); } } int value= check(); if( value==0) { // cout<<"in"<<endl; float sum=0; float number=0; float mean=0; for( int y=0; y<N; y++) { for( int x=0; x<M; x++) { if( !(map[y][x]==0)) { sum+=map[y][x]; number++; } } } if(!( number==0)) { mean=sum/number; // cout<<mean<<endl; for( int y=0; y<N; y++) { for( int x=0; x<M; x++) { if( !(map[y][x]==0)) { if( map[y][x]>mean) { map[y][x]--; } else if( map[y][x]<mean) { map[y][x]++; } } } } } } } int ans=0; for( int y=0; y<N; y++) { for( int x=0; x<M; x++) { ans+=map[y][x]; } } cout<<ans; //cout<<"Hello World"; //multi //0 -> cw, 1->ccw// distance return 0; }
댓글을 작성하려면
로그인
해야 합니다.
zelot11 4년 전
혹시 반례나 어디가 잘 못 되었는지 알 수 있을까용??