top of page

게시판 게시물

september15em
2021년 8월 17일
In 소스 코드 제출
/* #include <iostream> #include <vector> #include <cstdio> #include <queue> #include <cstdlib> using namespace std; vector<char> graph[255]; int N,M; int toll[256][256]; ///A -> ? int near[256]; ///bfs or dfs 의 visted char start; char goal; int nearest(char location,int pay) { int a; int best=-1; char best_shot; int i; if(location==goal) { return pay; } if(near[location]==-1||near[location]>pay) { near[location] = pay; } else { return -1; } //printf("%c ",location); for(i = 0; i < graph[location].size(); i++) { a = nearest(graph[location][i],pay+toll[location][graph[location][i]]); if(best == -1||best > a&&a!=-1) {//printf("\n%c ",location); best = a; best_shot = graph[location][i]; } } if(best != -1) { //best += toll[location][best_shot]; //printf("|"); } return best; } int main() { int i; int input3; char input1,input2; for(i = 0; i < 256; i++) { near[i] = -1; } scanf("%d %d ",&N,&M); for(i = 0; i < M; i++) { scanf("%c %c %d ",&input1,&input2,&input3); graph[(int)input1].push_back(input2); graph[(int)input2].push_back(input1); toll[(int)input1][(int)input2]=input3; toll[(int)input2][(int)input1]=input3; } scanf("%c %c",&start,&goal); //puts(""); printf("%d",nearest(start,0)); return 0; }*/ #include <iostream> #include <vector> #include <cstdio> #include <queue> #include <cstdlib> using namespace std; const int px[4] = {-1,1,0,0}; const int py[4] = {0,0,-1,1}; const char pc[5] = "DULR"; int canmove; queue<int> que[2]; //xy queue<char*> answer; char map[100][100]; bool visted[100][100]; vector<int> fire[2]; int n,m; int ex,ey; int abs(int n){return n<0?-n:n;} char* bfs() { char str[1000]; int i=0,j,k,days=0; int ways=1; int after_ways=1; while(ways!= 0) { ways = after_ways; after_ways = 0; days++; for(i = 0;i < ways;i++) { for(j = 0;j < 4;j++) { sprintf(str,"%s%c",answer.back,pc[j]); if(que[0].back()+py[j]<0||que[1].back()+px[j]<0) { continue; } if(que[0].back()+py[j]==ey||que[1].back()+px[j]==ex) { printf(str); } if(que[0].back()+py[j]>=n||que[1].back()+px[j]>=m) { out: continue; } for(k = 0;k < fire[1].size();k++) { if(abs((int)que[0].back()+py[j]-fire[0])+abs((int)que[1].back()+px[j]-fire[1])<=days/canmove) { goto out; } } que[0].push(que[0].back()+py[j]); que[1].push(que[1].back()+px[j]); answer.push(str); after_ways++; } que[1].pop(); que[2].pop(); answer.pop(); } } } int main() { int i,j; scanf("%d%d%d ",&n,&m,&canmove); for(i = 0;i < n;i++) { for(j = 0;j < m;j++) { scanf("%c",&map[i][j]); if(map[i][j]=='F') { fire[0].push_back(i); fire[1].push_back(j); } if(map[i][j]=='Y') { que[0].push(i); que[1].push(j); } if(map[i][j]=='E') { ey=i; ex=j; } } scanf(" "); } answer.push(""); bfs(); }
0
1
10
september15em
2021년 1월 19일
In 소스 코드 제출
/* * GLUT Shapes Demo * * Written by Nigel Stewart November 2003 * * This program is test harness for the sphere, cone * and torus shapes in GLUT. * * Spinning wireframe and smooth shaded shapes are * displayed until the ESC or q key is pressed. The * number of geometry stacks and slices can be adjusted * using the + and - keys. */ #include <windows.h> #ifdef __APPLE__ #include <GLUT/glut.h> #else #include <GL/glut.h> #endif #include <stdlib.h> static int slices = 16; static int stacks = 16; /* GLUT callback Handlers */ //float x[4] = {0.9,-0.1,-0.1,0.9},y[4]={0.9,0.9,-0.1,-0.1}; class project { public: float x[3]={0,0.5,0.5}; float y[3]={0,0.75,-0.25}; float ge = 1; void print_test(void) { glColor3f(1,0,0); glBegin(GL_POLYGON); glVertex3f(x[0],y[0],0); glVertex3f(x[1],y[1],ge); glVertex3f(x[2],y[2],ge); glEnd(); glBegin(GL_POLYGON); glVertex3f(x[0]-0.1,y[0],0); glVertex3f(x[1]-0.1,y[1],ge); glVertex3f(x[2]-0.1,y[2],ge); glEnd(); glColor3f(1,0.5,0.5); glBegin(GL_POLYGON); glVertex3f(x[0],y[0],0); glVertex3f(x[0]-0.1,y[0],0); glVertex3f(x[1]-0.1,y[1],0); glVertex3f(x[1],y[1],ge); glEnd(); glColor3f(0.8,0,0); glBegin(GL_POLYGON); glVertex3f(x[0],y[0],0); glVertex3f(x[0]-0.1,y[0],0); glVertex3f(x[2]-0.1,y[2],ge); glVertex3f(x[2],y[2],0); glEnd(); } }; float n = 2.5; project p; static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); p.print_test(); /* y[1] += 0.00001; x[1] += 0.00001; */ glFlush(); glutSwapBuffers(); } static void key(unsigned char key, int xl, int yl) { switch (key) { case 27 : case 'q': exit(0); break; break; } glutPostRedisplay(); } static void idle(void) { glutPostRedisplay(); } /* Program entry point */ int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(480,480); glutInitWindowPosition(10,10); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("GLUT Shapes"); glutDisplayFunc(display); glutKeyboardFunc(key); glutIdleFunc(idle); glClearColor(1,1,1,1); glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH); glEnable(GL_CW); glEnable(GL_SMOOTH); glutMainLoop(); return EXIT_SUCCESS; }
0
0
1
september15em
2020년 12월 01일
In 소스 코드 제출
#include<iostream> #include <stdio.h> using namespace std; int main(int argc, char** argv) { int test_case; int T; int a,b,c; int an; scanf("%d",&T); for(test_case = 1; test_case <= T; ++test_case) { scanf("%d %d %d",&a,&b,&c); an = b > c?c:b; printf("#%d %d ",test_case,an); an = (a-c-b)*-1; printf("%d\n",an<0?0:an); } }
0
0
2
september15em
2020년 11월 24일
In 소스 코드 제출
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <algorithm> using namespace std; struct sesi { private: protected: public: long long a; long long b; long long hap; }; bool cmp(sesi a,sesi b) { return a.hap > b.hap; } int main() { sesi s[10000]; long long n,t; long long i,j,test_case; long long a_sum,b_sum; scanf("%lld",&t); for(test_case=1;test_case<=t;test_case++) { a_sum = 0; b_sum = 0; scanf("%lld",&n); for(i = 0;i < n;i++) { scanf("%lld %lld",&s[i].a,&s[i].b); s[i].hap = s[i].a+s[i].b; } sort(s,s+n,cmp); s[n].hap = 0; s[n].b = 0; for(i = 0; i < n;) { a_sum += s[i].a; i++; b_sum += s[i].b; i++; } printf("#%lld %lld\n",test_case,a_sum-b_sum); } }
0
0
1
september15em
2020년 11월 17일
In 소스 코드 제출
/* #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> using namespace std; template<typename T> class stack { private: unsigned int size = 0; T main_arr[10000]; public: bool empty(void) { return !size; } T top(void) { return main_arr[size-1]; } void pop(void) { size--; } void push(T input) { main_arr[size] = input; size++; } void clear(void) { size = 0; } }; bool open(char a) { if(a=='<'||a=='('||a=='{'||a=='[') { return 1; } return 0; } bool close(char a) { if(a=='>'||a==')'||a=='}'||a==']') { return 1; } return 0; } bool match(char a,char b) { if(a=='<'&&b=='>') { return 1; } if(a=='('&&b==')') { return 1; } if(a=='{'&&b=='}') { return 1; } if(a=='['&&b==']') { return 1; } return 0; } int main() { stack<char> st; char temp[10000]; int n,i; int test; bool answer; for(test = 1;test <= 10;test++) { answer = 1; scanf("%d ",&n); scanf("%s",temp); for(i = 0;i < n;i++) { //printf("%c",temp); if(close(temp[i])&&answer) { if(st.empty()) { answer = false; } else if(match(st.top(),temp[i])) { st.pop(); } else { answer = false; } } if(open(temp[i])) { st.push(temp[i]); } } answer = st.empty()&answer; printf("#%d %d\n",test,answer); st.clear(); } } */ /* #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> int t= 1; struct a { int lo; int num; }; int main() { int arr[2000] = {0,}; int i,j; int n; a small,big; scanf("%d",&n); for(i = 0; i < 100; i++) { scanf("%d ",&arr[i]); } for( i =0; i < n; i++) { big.num = -1; small.num = 24545646; for(j = 0; j < 100; j++) { if(small.num > arr[j]) { small.lo = j; small.num = arr[j]; } if(big.num < arr[j]) { big.lo = j; big.num = arr[j]; } } arr[big.lo]--; arr[small.lo]++; } big.num = -1; small.num = 24545646; for(j = 0; j < 100; j++) { if(small.num > arr[j]) { small.lo = j; small.num = arr[j]; } if(big.num < arr[j]) { big.lo = j; big.num = arr[j]; } } printf("#%d %d\n",t,big.num-small.num); t++; if(t!=11) main(); } **/ #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { int n; }
0
0
1
september15em
2020년 11월 10일
In 소스 코드 제출
/* #include <iostream> #include <stdio.h> #include <map> #include <string.h> using namespace std; class tree { public: int arr[2]= {0,0}; int cnt = 0; char main_ = 0; }; tree t[500]; void f(int n) { int i; if(t[n].main_ == 0) { return; } f(t[n].arr[0]); printf("%c",t[n].main_); f(t[n].arr[1]); } int main() { int test; int n; int i,j; int x; char str[100]; int num; for(test = 1; test <= 10; test++) { scanf("%d ",&n); for(i = 0; i < n; i++) { num = 0; scanf("%d ",&x); gets(str); //printf("a %d %s\n",strlen(str),str); t[x].main_ = str[0]; if(strlen(str)!= 1) { /// for(j = 2; str[j]<='9'&&str[j]>='0'; j++) { num=(num*10)+(str[j]-'0'); // printf("a"); } t[x].arr[0] = num; if(strlen(str)!=j) { num = 0; for(j++;str[j]<='9'&&str[j]>='0'; j++) { num=(num*10)+(str[j]-'0'); } t[x].arr[1] = num; } else { t[x].arr[1] = 0; } } else { t[x].arr[0] = 0; t[x].arr[1] = 0; } } printf("#%d ",test); f(1); puts(""); } } */ /* #include <iostream> #include <stdio.h> #include <map> #include <string.h> #include <stdlib.h> using namespace std; struct grape { int arr[3]; int cnt = 0; }; grape fruit[101]; bool visted[101]; bool f(int n) { // printf("%d,",n); bool a; if(n == 99) { return true; } if(n>=100||visted[n]) { return false; } visted[n] = true; a = f(fruit[n].arr[0]); if(a) { return a; } a = f(fruit[n].arr[1]); return a; } int main() { int n,m; int test; int x; int i; for(test = 1; test <= 10; test++) { memset(visted,false,sizeof(visted)); for(i = 0; i < 100; i++) { fruit[i].cnt = 0; memset(fruit[i].arr,100,sizeof(fruit[i].arr)); } scanf("%d %d",&test,&x); for(i = 0;i < x;i++) { scanf("%d %d",&n,&m); fruit[n].arr[fruit[n].cnt] = m; fruit[n].cnt++; } printf("#%d %d\n",test,f(0)); } } */ #include <iostream> #include <stdio.h> #include <stack> #include <string.h> #include <stdlib.h> using namespace std; bool open(char a) { if(a=='<'||a=='('||a=='{'||a=='[') { return 1; } return 0; } bool close(char a) { if(a=='>'||a==')'||a=='}'||a==']') { return 1; } return 0; } bool match(char a,char b) { if(a=='<'&&b=='>') { return 1; } if(a=='('&&b==')') { return 1; } if(a=='{'&&b=='}') { return 1; } if(a=='['&&b==']') { return 1; } return 0; } int main() { stack<char> st; char temp[10000]; int n,i; int test; bool answer; for(test = 1;test <= 10;test++) { answer = 1; scanf("%d ",&n); scanf("%s",temp); for(i = 0;i < n;i++) { //printf("%c",temp); if(close(temp[i])&&answer) { if(st.empty()) { answer = false; } else if(match(st.top(),temp[i])) { st.pop(); } else { answer = false; } } if(open(temp[i])) { st.push(temp[i]); } } answer = st.empty()&&answer; printf("#%d %d\n",test,answer); } }
0
0
0
september15em
2020년 11월 03일
In 소스 코드 제출
/* #include <cstdio> #include <string.h> using namespace std; int main() { char map[10][10]; char str[10]; int answer; int l; int n; int t; int i; int k,j; //return 0; //printf("%d",3/2); for(t =1; t<= 10; t++) { scanf("%d",&n); answer = 0; for(i = 1; i <= 8; i++) { scanf("%s",&map[i][1]); //printf("%s\n",&map[i][1]); } for(i = 1; i <= 8; i++) { for(j = 1; j <= 8-(n-1); j++) { for(k = 0; k < n/2; k++) { str[k] = map[i][k+j]; } for(k = j+((n/2))+(n%2),l = (n/2)-1; l >= 0; k++,l--) { if(map[i][k] == str[l]) { continue; } else { break; } } if(l == -1) { // printf("%d %s %d %d 가로\n",answer,str,i,j); answer++; } for(k = 0; k < n/2; k++) { str[k] = map[k+j][i]; } for(k = j+((n/2))+(n%2),l = (n/2)-1; l >= 0; k++,l--) { if(map[k][i] == str[l]) { continue; } else { break; } } if(l == -1) { //printf("%d %s %d %d 세로\n",answer,str,j,i); answer++; } } } printf("#%d %d\n",t,answer); } } */ /* #include <cstdio> int x; int f(int n) { if(x == 1) { return 1; } if(n==0) { return 1; } return x*f(n-1); } int main() { int t; int n; for(t = 1;t <= 10;t++) { scanf("%d %d %d",&t,&x,&n); printf("%d\n",f(n)); } } */
0
0
1
september15em
2020년 10월 27일
In 소스 코드 제출
/* #include <iostream> #include <stdio.h> #include <string.h> #include <stack> #include <queue> #include <stdlib.h> using namespace std; /// char str[10000]; int search(const int start,const int end) { int arr[end-start]; int c_cnt =0; int cnt = 0; int answer=0; int i; int j; int x = 0; for(i = start; i <= end; i++) { if(str[i]>='0'&&str[i]<='9') { if(i-1!=-1&&str[i-1]=='*') { arr[cnt-1] *= str[i]-'0'; } else { arr[cnt] = str[i]-'0'; cnt++; } } else if(str[i]=='(') { x =1; for(j = i+1; x != 0; j++) { if(str[j] == '(') { x++; } if(str[j] == ')') { x--; } } if(i-1!=-1&&str[i-1]=='*') { arr[cnt-1] *= search(i+1,j-1); } else { arr[cnt] = search(i+1,j-1); cnt++; } x = 0; i = j-1; } } for(i = 0;i < cnt;i++) { answer += arr[i]; } return answer; } int main() { stack<char> st; int n; int i; int test; for(test = 1; test <= 10; test++) { //scanf("%d",&n); scanf("%s",str); printf("#%d %d\n",test,search(0,strlen(str)-1)); } } */ #include <stdio.h> int main() { char map[10][10]; char str[8]; int answer=0; int i,j; int n; int test = 1; for(test=1;test <= 10;test++) { answer = 0; scanf("%d",&n); for(i =0;i < 8;i++) { scanf("%s",map[i]); } for(i = 0;i < 8;i++) { } } }
0
0
1
september15em
2020년 10월 20일
In 소스 코드 제출
/* #include <iostream> #include <stdio.h> using namespace std; int memo[100000107]={0,}; int answer; int p(int n) { } int f(int n) { int i; if(n==0) { return 1; } if(memo[n]) { return memo[n]; } for(i = 1;i <= n;i++) { memo[n]+=(f(n-i))%1000000007; memo[n]%= 1000000007; } return memo[n]; } int main() { //freopen("input.txt", "r", stdin); cout <<<< endl; return 0; } */ /* #include <iostream> #include <stdio.h> using namespace std; int main() { int n,m; cin >> n>>m; if(n==1&&m==2) { printf("B"); } else if(m==1&&n==2) { printf("A"); } else if(n==2&&m==3) { printf("B"); } else if(m==2&&n==3) { printf("A"); } else if(n==3&&m==1) { printf("B"); } else { printf("A"); } } */ /** //복붙용 #include <stdio.h> int main() { } */ /* #include <stdio.h> #include <string.h> int main() { int arr[1010]= {0,}; int answer=0; int i,j; int n; int num=0; while(scanf("%d",&n)!=EOF) { num++; answer=0; for( i= 0; i < n; i++) { scanf("%d",&arr[i]); } for(i = 2; i < n; i++) { int big = 0; for(j = -2; j <= 2; j++) { if(j==0) { continue; } if(big < arr[i+j]) { big = arr[i+j]; } } if(arr[i]-big >=0) { answer+=(arr[i]-big); } } printf("#%d %d",num,answer); } } */ /* #include <stdio.h> #include <string.h> int main() { int t,k; char str[1010]={0,}; char rev[1010]={0,}; int i,j; scanf("%d",&t); for(k = 1;k <= t;k++) { scanf("%s",&str); for(i = strlen(str)-1;i>=0;i--) { rev[strlen(str)-1-i]=str[i]; } strcpy(str,rev); for(i = 0;i < strlen(str);i++) { switch(str[i]) { case 'q': str[i] = 'p'; break; case 'p': str[i] = 'q'; break; case 'b': str[i] = 'd'; break; case 'd': str[i] = 'b'; break; } } printf("#%d %s\n",k,str); } } */
0
0
1
september15em
2020년 9월 15일
In 소스 코드 제출
#include <queue> #include <vector> using namespace std; int solution(int bridge_length, int weight, vector<int> truck_weights) { int answer = 0; queue<int> bridge; queue<int> time; int go_truck = 0; int clear_truck = 0; int hap = 0; int i; while(clear_truck < truck_weights.size()) { answer++; if(hap+truck_weights[go_truck] <= weight&&go_truck<=truck_weights.size()-1) { bridge.push(truck_weights[go_truck]); hap+=truck_weights[go_truck]; time.push(answer); go_truck++; } if(time.front()-answer>=bridge_length-1) { clear_truck++; hap-=bridge.front(); bridge.pop(); time.pop(); } } return answer; }
0
0
3
september15em
2020년 8월 11일
In 소스 코드 제출
#include <string> #include <vector> #include <queue> using namespace std; int solution(vector<int> priorities, int location) { int answer = 0; int i,j,k; bool check = false; bool out_check=false; queue<int> list; queue<int> num; int out[110]={0,}; int out_size=0; for(i = 0;i < priorities.size();i++) { list.push(priorities[i]); num.push(i); } while(1) { check=false; out_check=true; for(i = 0; i < priorities.size();i++) { out_check=true; for(j = 0;j < out_size;j++) { if(i == out[j]) { out_check=false; break; } } if(list.front()<priorities[i]&&out_check) { list.push(list.front()); list.pop(); num.push(num.front()); num.pop(); check = true; break; } } if(!check) { answer++; if(num.front()==location) { break; } out[out_size]=num.front(); out_size++; num.pop(); list.pop(); } } return answer; }
0
0
2
september15em
2020년 8월 04일
In 소스 코드 제출
//C++ STL header #include <string> #include <vector> #include <algorithm> #include <map> using namespace std; bool desc(int a, int b) { return a >= b; } vector<int> solution(vector<string> genres, vector<int> plays) { int size; int count=0; int genres_num[100000]; //장르 sort map<string,bool> check; map<string,map<int,int> > lotate_count; string name[1000]; //이름저장 vector<int> answer; map<int,string> play_and_genres; //횟수별 장르 map<string,int> total_plays; //장르별 들었던 횟수 map<string,vector<int> > genres_song; //장르 내 노래 map<string,map<int,map<int,int> > > lotate; //식별 번호 int i,j; for(i = 0; i < genres.size();i++) { lotate[genres[i]][plays[i]][lotate_count[genres[i]][plays[i]]]=i; lotate_count[genres[i]][plays[i]]++; genres_song[genres[i]].push_back(plays[i]); total_plays[genres[i]]+=plays[i]; if(!check[genres[i]]) { check[genres[i]]=true; name[count]=genres[i]; count++; } } lotate_count.clear(); for(i = 0;i < count;i++) { genres_num[i]=total_plays[name[i]]; play_and_genres[total_plays[name[i]]]=name[i]; } sort(genres_num,genres_num+count,desc); for(i = 0;i < count;i++) { sort(genres_song[play_and_genres[genres_num[i]]].begin(),genres_song[play_and_genres[genres_num[i]]].end(),desc); size = genres_song[play_and_genres[genres_num[i]]].size(); if(size == 1) { for(j = 0;j < 1;j++) { answer.push_back(lotate[play_and_genres[genres_num[i]]][genres_song[play_and_genres[genres_num[i]]][j]][lotate_count[play_and_genres[genres_num[i]]][genres_song[play_and_genres[genres_num[i]]][j]]]); } } else { for(j = 0;j < 2;j++) { answer.push_back(lotate[play_and_genres[genres_num[i]]][genres_song[play_and_genres[genres_num[i]]][j]][lotate_count[play_and_genres[genres_num[i]]][genres_song[play_and_genres[genres_num[i]]][j]]]); lotate_count[play_and_genres[genres_num[i]]][genres_song[play_and_genres[genres_num[i]]][j]]++; } } } return answer; }
0
0
1
september15em
2020년 7월 21일
In 소스 코드 제출
/*//실패 #include <stdio.h> #include <stdlib.h> int map[1000]={0,}; int n; int num[1000]={0,}; int check(void) { int i; int arr[1000]={0,}; for(i = 1;i<=n;i++) { arr[i]=num[i-1]+num[i]+num[i+1]; if(arr[i]==map[i]) { continue; } else { return 0; } } return 1; } int okay(int num1) { } int main() { int i,j; scanf("%d",&n); for(i = 1;i<=n;i++) { scanf("%d",&map[i]); if(map[i]>300) { printf("-1"); return 0; } } okay(1) if() { for(i = 1;i<=n;i++) { printf("%d ",num[i]); } } else{ printf("-1"); } // return 0; return -1073741510; } */ /* #include <stdio.h> int arr[2001][2001]={0,}; int size[2001]={0,}; int visted[2001]={0,}; int queue[2001]={1,0,}; int queue_size=1; int que_start=0; void put(int lo,int put_num) { arr[lo][size[lo]]=put_num; size[lo]++; } void out(int lo) { int i; for(i = 0;i< size[lo];i++) { if(!visted[arr[lo][i]]) { queue[queue_size]=arr[lo][i]; queue_size++; visted[arr[lo][i]]=1; } } } int main() { ///printf("aa"); int n,m; int a,b; int i; scanf("%d%d",&n,&m); for(i =0;i<m;i++) { scanf("%d%d",&a,&b); put(a,b); put(b,a); } //printf("1"); visted[1]=1; while(queue_size<n) { que_start = queue_size-1; for(i = que_start;i<queue_size;i++) { out(queue[i]); } } for(i = 0;i < queue_size;i++) { printf("%d ",queue[i]); } } **/
0
0
1
september15em
2020년 6월 30일
In 소스 코드 제출
/* #include <stdio.h> /** 1,3,5, 7,9,11월은 31일 2월은 29 4,6,8, 10,12월은 30일 while(3/1&&11/30) const int amonth[13]= {12,1,2,3,4,5,6,7,8,9,10,11,12}; const int aday[13]= {31,31,28,31,30,31,30,31,31,30,31,30,31}; struct flower { int start_month; int start_day; int end_month; int end_day; }; struct flower plant[100000]; int main() { /// 0 1 2 3 4 5 6 7 8 9 10 11 12 //printf("%d",(6*31)+29+(5*30)); int i,j,n; int start_day=1; int start_month=3; int big_month=3; int big_day=1; int count=0; int m=1; //printf("%d",(5*31)+28+(4*30)); scanf("%d",&n); for(i=0; i < n; i++) { scanf("%d",&plant[i].start_month); scanf("%d",&plant[i].start_day); scanf("%d",&plant[i].end_month); scanf("%d",&plant[i].end_day); /*plant[i].end_day--; if(plant[i].end_day==0) { plant[i].end_month=amonth[plant[i].end_month-1]; plant[i].end_day=aday[plant[i].end_month]; } /* if(plant[i].start_month<start_month) { plant[i].start_month = 3; plant[i].start_day = 1; }*/ /* } for(; m!=0;) { m=0; for(i=0; i<n; i++) { if(plant[i].start_month<start_month) { //if(plant[i].start_day<=start_day) { if(plant[i].end_month==12) { printf("%d",count+1); return 100; } if(plant[i].end_month>big_month) { big_month = plant[i].end_month; big_day = plant[i].end_day; m++; } else if(plant[i].end_month==big_month) { if(plant[i].end_day>big_day) { big_month = plant[i].end_month; big_day = plant[i].end_day; m++; } } } } else if(plant[i].start_month==start_month) { if(plant[i].start_day<=start_day) { if(plant[i].end_month==12) { printf("%d",count+1); return 100; } if(plant[i].end_month>big_month) { big_month = plant[i].end_month; big_day = plant[i].end_day; m++; } else if(plant[i].end_month==big_month) { if(plant[i].end_day>big_day) { big_month = plant[i].end_month; big_day = plant[i].end_day; m++; } } } } } count++; start_day = big_day; start_month = big_month; } printf("0"); } */ /* #include <stdio.h> int n; int m; int qx[4]= {0,0,-1,1}; int qy[4]= {-1,1,0,0}; int visited[102][102][101]= {{{0,},},}; int map[102][102]= {{0,},}; int go(int x,int y,int minx,int miny,int nopi) { if(visited[y+miny][x+minx][nopi]==0&&map[y+miny][x+minx]!=0) { return 1; } return 0; } void bfs(int x,int y,int nopi) { int i; visited[y][x][nopi]=1; if(map[y][x]<= nopi) { return; } else { for(i=0; i < 4; i++) { if(go(x,y,qx[i],qy[i],nopi)==1) { bfs(x+qx[i],y+qy[i],nopi); } } } } int main() { int when; int i,j,k; int big = -1; int count=0; scanf("%d",&n); for(i=1; i<=n; i++) { for(j=1; j <= n; j++) { scanf("%d",&map[i][j]); } } for(k = 3; k<=100; k++) { count=0; for(i=1; i<=n; i++) { for(j=1; j <= n; j++) { if(map[i][j]>k) { if(go(j,i,0,0,k)==1) { count++; bfs(j,i,k); } } } } if(big <= count) { big = count; when=k; } } printf("%d %d",big,when); } */ ///4039 : 놀이공원,5024 : 공격적인 소들,3002 : 기억력 테스트 3 #include <stdio.h> #define not 87310 int map[1002][1002]={{0,},}; int qx[4]= {0,0,-1,1}; int qy[4]= {-1,1,0,0}; int n,m; int visted[1002][1002]={{0,},}; int f(int n) { if(n < 0) { return n*-1; } return n; } int find(int x,int y) { if(visted[y][x]==0&&map[y][x]!=0) { return 1; } return 0; } int go(int x,int y) { int i; int xv; if(x==m&&y==n) { return 1; } int n =not; for(i =0;i <4;i++) { if(find(x-qx[i],y-qy[i])) { if(f(map[y][x]-map[y-qy[i]][x-qx[i]])==1||f(map[y][x]-map[y-qy[i]][x-qx[i]])==0) { xv = go(x-qx[i],y-qy[i]); if(xv<n) { n=xv+1; } } } } return n; } int main() { int i,j; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%d",&map[i][j]); } } n=go(1,1); if(n==not) { printf("0"); return 0; } printf("%d",n); }
0
0
7
september15em
2020년 6월 23일
In 소스 코드 제출
/* #include <stdio.h> struct tree { int end; int start; int big; }; #define no -100 struct tree wood[50002][20]; int max_floor=1; int find(int n,int m,int lotat,int floor) { //int i,j; int big = no; int temp; if(wood[lotat][floor].start>=n) { if(wood[lotat][floor].end<=m) { return wood[lotat][floor].big; } } ///찾아봐요 버그의 숲 else if(wood[lotat][floor].start<n) { ///n = start ///m = end ///n ~ m ///start ~ end if(wood[lotat][floor].end>m) { temp = find(n,m,lotat*2,floor-1); if(big < temp) { big = temp; } temp = find(n,m,(lotat*2)-1,floor-1); if(big < temp) { big = temp; } } else if(wood[lotat][floor].end<=m) { if(wood[lotat][floor].end>=n) { temp = find(n,m,lotat*2,floor-1); if(big < temp) { big = temp; } temp = find(n,m,(lotat*2)-1,floor-1); if(big < temp) { big = temp; } } } } if(wood[lotat][floor].end>m) { if(wood[lotat][floor].start<=m) { temp = find(n,m,lotat*2,floor-1); if(big < temp) { big = temp; } temp = find(n,m,(lotat*2)-1,floor-1); if(big < temp) { big = temp; } } } return big; } int main() { int n,m,i,j; int musigi; scanf("%d",&n); for(i = 1; i <= n; i++) { scanf("%d",&wood[i][0].big); wood[i][0].end =i; wood[i][0].start = i; } for(i=n; i!=1; i=(i/2)+(i%2)) { for(j=1; j<=i; j++) { if(j%2==0) { wood[j/2][max_floor].end=wood[j][max_floor-1].end; wood[j/2][max_floor].start=wood[j-1][max_floor-1].start; wood[j/2][max_floor].big=wood[j][max_floor-1].big > wood[j-1][max_floor-1].big?wood[j][max_floor-1].big:wood[j-1][max_floor-1].big; } } if(i%2==1) { wood[i/2+1][max_floor].end=wood[i][max_floor-1].end; wood[i/2+1][max_floor].start=wood[i][max_floor-1].start; wood[i/2+1][max_floor].big = wood[i][max_floor-1].big; } max_floor++; } max_floor--; //printf("%d",max_floor); scanf("%d",&musigi); for(i = 1; i <= musigi; i++) { scanf("%d%d",&n,&m); printf("%d ",find(n,m,1,max_floor)); } } */ #include <stdio.h> int main() { int i,j; int x; int d1,d2; scanf("%d%d",&d1,&d2); x = d1; x *= ((d2-d1)-(d2-d1)/6); x += d1 * (d2-d1)/12; printf("%d",&x); }
0
0
1
september15em
2020년 6월 16일
In 소스 코드 제출
#include <stdio.h> int arr[50001][20]; int find_num(int n,int m) { int big = -1; int floor=0; if(n==m) { return arr[n][0]; } while(n<m) { if(n%2==1) { if(big < arr[n][floor]) { big = arr[n][floor]; } n +=1; } else if(n%2==0) { if(big < arr[n][floor]) { big = arr[n][floor]; } n+=2; } if(m%2==1) { if(big < arr[m][floor]) { big =arr[m][floor]; } m-=1; } m /= 2; n /= 2; floor++; } if(big < arr[m][floor]) { big = arr[m][floor]; } return big; } int main() { int n,m,j,i,h; int size; int old; scanf("%d",&n); size = n; old = n; for(i = 1; i <= n; i++) { scanf("%d",&arr[i][0]); } for(i = 1; size != 1; i++) { for(j = 1; j <= size; j++) { if(j%2 == 0) arr[j/2][i] = arr[j][i-1]>arr[j-1][i-1]?arr[j][i-1]:arr[j-1][i-1]; } if(size%2 == 1) { arr[size/2][i] = arr[old][i-1]; } old = size; size = (size/2) + (size%2); } scanf("%d",&m); for(i = 0; i < m; i++) { scanf("%d%d",&h,&n); size = find_num(h,n); printf("%d ",size); } } /** 50000*50000 1 1 2 1 2 34 123 456 78 */
0
0
1
september15em
2020년 6월 09일
In 소스 코드 제출
/** ///전설의 코드 #include <stdio.h> int map[21][21]={{0,},}; int vis[21][21][3][3]={{{{0,},},},}; int realx,realy; char find_map(int my,int mx,int y,int x,int find) { if(map[y+my][x +mx] == find&&vis[y+my][x+mx][1+my][1+mx]==0) { //printf("\na: %d %d\n ",find,map[y+my][x +mx]); return 1; } else { //printf("%d:%d:%d ",find,map[y+my][x +mx],vis[y][x][1+my][1+mx]); return 0; } } char sreach(int my,int mx,int y,int x,int count,int find) { char xx=0; vis[y][x][1+my][1+mx] = 1; vis[y][x][1+(my*-1)][1+(mx*-1)] = 1; //printf("\nnuw %d\n",count); if(count == 1) { if(find_map(1,0,y,x,find)==1) { vis[y][x][1+1][1+0] = 1; xx = sreach(1,0,y+1,x,count+1,find); if(xx==1) { return 1; } } if(find_map(0,1,y,x,find)==1) { vis[y][x][1][1+1] = 1; xx= sreach(0,1,y,x+1,count+1,find); if(xx==1) { return 1; } } if(find_map(-1,0,y,x,find)==1) { vis[y][x][1-1][1+0] = 1; xx= sreach(-1,0,y-1,x,count+1,find); if(xx==1) { return 1; } } if(find_map(0,-1,y,x,find)==1) { vis[y][x][1+0][1-1] = 1; xx= sreach(0,-1,y,x-1,count+1,find); if(xx==1) { return 1; } } if(find_map(1,1,y,x,find)==1) { vis[y][x][1+1][1+1] = 1; xx= sreach(1,1,y+1,x+1,count+1,find); if(xx==1) { return 1; } } if(find_map(-1,-1,y,x,find)==1) { vis[y][x][1-1][1-1] = 1; xx= sreach(-1,-1,y-1,x-1,count+1,find); if(xx==1) { return 1; } } if(find_map(1,-1,y,x,find)==1) { vis[y][x][1+1][1-1]=1; xx= sreach(1,-1,y+1,x-1,count+1,find); if(xx==1) { return 1; } } if(find_map(-1,1,y,x,find)==1) { vis[y][x][1-1][1+1] = 1; xx= sreach(-1,1,y-1,x+1,count+1,find); if(xx==1) { return 1; } } return 0; } else if(find_map(my,mx,y,x,find)==1) { return sreach(my,mx,y+my,x+mx,count+1,find); } else if(count ==5) { if(realx > x) { realx = x; realy = y; } else if(realy > y) { realy = y; } return 1; } else { return 0; } } int main() { int i,j; for(i = 1;i<=19;i++) { for(j =1;j<=19;j++) { scanf("%d",&map[i][j]); } } for(i = 1;i<=19;i++) { for(j =1;j<=19;j++) { if(map[i][j] != 0) { //printf("\ng"); realx = j; realy = i; if(sreach(0,0,i,j,1,map[i][j])==1) { printf("%d\n%d %d",map[i][j],realy,realx); return 0; } } } } printf("%d",0); } */
0
0
1
september15em
2020년 6월 02일
In 소스 코드 제출
/* #include <stdio.h> int move(int i,int arr[][101],int arrsize[],int atact[]) { int j; int x = 0; if(!atact[i]) for(j = 0; j < arrsize[i]; j++) { if(atact[arr[i][j]] == 1) { x += 1; atact[i] = 1; goto a; } } if(atact[i]) { x++; a: for(j = 0; j < arrsize[i]; j++) { if(atact[arr[i][j]]==0) { atact[arr[i][j]] = 1; x += move(arr[i][j],arr,arrsize,atact); } } } return x; } int main() { int arr[100][101]= {{0,},}; int arrsize[100]= {0,}; int atact[100]= {0,}; atact[1] = 1; int i,n,m,j; int k,l,count=0; scanf("%d%d",&n,&m); for(i = 0; i < m; i++) { scanf("%d %d",&k,&l); arr[k][arrsize[k]] = l; arrsize[k]++; arr[l][arrsize[l]] = k; arrsize[l]++; } count = move(1,arr,arrsize,atact); printf("%d",count-1); } */ #include <stdio.h> int m,n,h; int py[6] = {1,-1,0,0,0,0}; int px[6] = {0,0,1,-1,0,0}; int pz[6] = {0,0,0,0,-1,1}; int arr[5000000][3]; int start=0; int f(int map[][110][110],int size) { int size2 = 0; int i,p; int aa; for(i = start; i < size; i++) { int y = arr[i][0]; int x = arr[i][1]; int z = arr[i][2]; for(p = 0; p <6; p++) { if(y+py[p] < h&&y+py[p] >= 0&&x+px[p] < n&&x+px[p] >= 0&&z+pz[p] < m&&z+pz[p] >= 0) { if(map[y+py[p]][x+px[p]][z+pz[p]]==0) { map[y+py[p]][x+px[p]][z+pz[p]]=1; arr[size2][0] = y+py[p]; arr[size2][1] = x+px[p]; arr[size2][2] = z+pz[p]; size2++; } } } } if(size2!=0) { int aa=f(map,size2); return aa+1==0?-1:aa+1; } for(i = 0;i < h;i++) { for(int j = 0;j < n;j++) { for(int k = 0;k < m;k++) { if(map[i][j][k] == 0) { return -1; } } } } return 0; } int main() { int arrsize=0,day; int map[110][110][110] = {{{0,},},}; int i,j,k; scanf("%d%d%d",&m,&n,&h); for(i = 0; i < h; i++) { for(j = 0; j < n; j++) { for(k = 0; k < m; k++) { scanf("%d",&map[i][j][k]); if(map[i][j][k]==1) { arr[arrsize][0] = i; arr[arrsize][1] = j; arr[arrsize][2] = k; arrsize++; } } } } day = f(map,arrsize); printf("%d",day); }
0
0
2
september15em
2020년 5월 26일
In 소스 코드 제출
/* #include <stdio.h> #include <stdlib.h> int queue[2][100000]; int end[2]; int start[2]; void push1(int n) { queue[0][end[0]] = n; end[0]++; } void push2(int n) { queue[1][end[1]] = n; end[1]++; } void pop1() { start[0]++; } void pop2() { start[1]++; } int main() { char c[101][101]; int visted[101][101] = {{0,}}; int i,j,k,l,count=0; int m,n,z; scanf("%d%d",&n,&m); for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { scanf(" %c",&c[i][j]); } } for(i = 0; i < m; i++) { for(j =0; j < n; j++) { if(c[i][j] == 'L'&&visted[i][j] == 0) { push1(i); push2(j); z++; count++; while(z != 0) { for(l=z,z=0; l>0; l--) { int x = queue[1][start[1]]; int y = queue[0][start[0]]; if(x-1!=-1&&!visted[y][x-1]&&c[y][x-1]=='L') { push1(y); push2(x-1); visted[y][x-1]=1; z++; } if(y-1!=-1&&!visted[y-1][x]&&c[y-1][x]=='L') { push1(y-1); push2(x); visted[y-1][x]=1; z++; } if(x+1!=n&&!visted[y][x+1]&&c[y][x+1]=='L') { push1(y); push2(x+1); visted[y][x+1]=1; z++; } if(y+1!=m&&!visted[y+1][x]&&c[y+1][x]=='L') { push1(y+1); push2(x); visted[y+1][x]=1; z++; } if(x+1!=n&&y+1!=m&&!visted[y+1][x+1]&&c[y+1][x+1]=='L') { push1(y+1); push2(x+1); visted[y+1][x+1]=1; z++; } if(x-1!=-1&&y-1!=-1&&!visted[y-1][x-1]&&c[y-1][x-1]=='L') { push1(y-1); push2(x-1); visted[y-1][x-1]=1; z++; } if(x-1!=-1&&y+1!=m&&!visted[y+1][x-1]&&c[y+1][x-1]=='L') { push1(y+1); push2(x-1); visted[y+1][x-1]=1; z++; } if(x+1!=n&&y-1!=-1&&!visted[y-1][x+1]&&c[y-1][x+1]=='L') { push1(y+1); push2(x-1); visted[y+1][x-1]=1; z++; } pop1(); pop2(); } } } } } printf("%d",count); } */ #include <stdio.h> int main() { int arr[100][100]= {{0,},}; int arrsize[100]= {0,}; int atact[100]= {0,}; atact[1] = 1; int i,n,m,j,o; int k,l,count=0; scanf("%d%d",&n,&m); for(i = 0; i < m; i++) { scanf("%d %d",&k,&l); arr[k][arrsize[k]] = l; arrsize[k]++; arr[l][arrsize[l]] = k; arrsize[l]++; } for(i = 1; i <= n; i++) { if(!atact[i]) for(j = 0; j < arrsize[i]; j++) { if(atact[arr[i][j]] == 1) { atact[i] = 1; break; } } if(atact[i]) { for(j = 0; j < arrsize[i]; j++) { if(atact[arr[i][j]] == 0) { atact[arr[i][j]] = 1; if(arr[i][j] < i) { int x = arr[i][j]; for(o = 0;o < arrsize[x];o++) { atact[arr[x][o]] = 1; } } } } } } for(i = 2; i <= n; i++) { count += atact[i]; } printf("%d",count); }
0
0
1
september15em
2020년 5월 19일
In 소스 코드 제출
/* #include <stdio.h> #include <stdlib.h> int memo[100000010]; long long f(int n) { if(n <= 1) { return 1; } if(memo[n]) { return memo[n]; } memo[n] = (f(n-1) + f(n-2))%100000007; return memo[n]; } int main() { int n,i; scanf("%d",&n); printf("%lld",f(n)); } */ /* #include <stdio.h> #include <math.h> int main() { int n,c=1; int i; scanf("%d",&n); if(n%3!=0) { printf("0"); return 0; } n /= 3; if(n == 2) { printf("2"); return 0; } for(i = 0;i < n;i++) { c *=2; c %= 100000007; } printf("%d",c); } */ /* #include <stdio.h> long long int memo[1000000]; long long f(int n) { if(n <= 1) { return 1; } if(memo[n]) { return memo[n]; } memo[n] = f(n-1) + 2*f(n-2)%100007; ////////////////////////////2367758 return memo[n]; } int main() { int n,i; scanf("%d",&n); printf("%lld",f(n)); } */ #include <stdio.h> int main() { int n,m = 0,c=1; int i; scanf("%d",&n); for(i = 0;i < n;i++) { c*=2; m += c <= 10?c:c-10; } m %= 100007; printf("%d",m); } /*** 1 5 11 33 87 */
0
0
3

september15em

더보기
bottom of page