제출 #307486

#제출 시각아이디문제언어결과실행 시간메모리
307486urd05Painting Squares (IOI20_squares)C++14
45 / 100
131 ms572 KiB
#include "squares.h" #include <bits/stdc++.h> using namespace std; vector<int> paint(int n) { vector<int> ret(n+1,1); int now=1; int ind=0; while (1) { int save=ind; while (ind<n&&ind<save+now) { ret[ind++]=0; } while (ind<n&&ind<save+now*2) { ret[ind++]=1; } if (ind==n) { break; } now++; } ret[n]=2*now+1; return ret; } int find_location(int n,vector<int> c) { int val0[50]; int val1[50]; for(int i=1;i<50;i++) { val0[i]=i*i-i; val1[i]=i*i; } int k=c.size(); if (c.back()==-1) { int ret=n-k; for(int i=k-1;i>=0;i--) { if (c[i]!=-1) { break; } ret++; } return ret; } int f=c[0]; for(int i=1;i<k;i++) { if (c[i]!=f) { int len; for(int j=i+1;j<k;j++) { if (c[j]==f) { len=j-i; break; } } int pos=(f==0?val1[len]:val0[len]); return pos-i; } } }

컴파일 시 표준 에러 (stderr) 메시지

squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
squares.cpp:54:26: warning: 'len' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |             int pos=(f==0?val1[len]:val0[len]);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...