제출 #386331

#제출 시각아이디문제언어결과실행 시간메모리
386331leinad2벽 칠하기 (APIO20_paint)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<vector<int> >B; int f(int a, int m) { if(a<0)while(a<0)a+=m; else while(a>=m)a-=m; return a; } int minimumInstructions(int N, int M, int K, vector<int>C, vector<int>A, vector<vector<int> >bB) { B=bB; int i, j, k; vector<int>X;X.resize(N); vector<vector<int> >S;S.resize(K); vector<int>cnt;cnt.resize(M); vector<int>chk;chk.resize(M+1); for(i=0;i<M;i++) { for(j=0;j<A[i];j++) { S[B[i][j]].push_back(i); } } for(i=0;i<M;i++) { for(j=0;j<S[C[i]].size();j++) { int a=f(i-S[C[i]][j], M); chk[cnt[a]]--; cnt[a]++; chk[cnt[a]]++; } } if(chk[M])X[0]=1; for(i=1;i<=N-M;i++) { for(j=0;j<S[C[i-1]].size();j++) { int a=f(i-1-S[C[i-1]][j], M); chk[cnt[a]]--; cnt[a]--; chk[cnt[a]]++; } for(j=0;j<S[C[i+M-1]].size();j++) { int a=f(i+M-1-S[C[i+M-1]][j], M); chk[cnt[a]]--; cnt[a]++; chk[cnt[a]]++; } if(chk[M])X[i]=1; } i=0; if(X[0]==0||X[N-M]==0)return -1; int ans=0; while(1) { if(i==N-M)return ans+1; k=-1; for(j=i+1;j<=i+M;j++) { if(X[j])k=j; } if(k==-1)return -1; i=k;ans++; } } int main() { int N, M, K; assert(3 == scanf("%d %d %d", &N, &M, &K)); vector<int> C(N); for (int i = 0; i < N; ++i) { assert(1 == scanf("%d", &C[i])); } vector<int> A(M); vector<vector<int> > B(M); for (int i = 0; i < M; ++i) { assert(1 == scanf("%d", &A[i])); B[i].resize(A[i]); for (int j = 0; j < A[i]; ++j) { assert(1 == scanf("%d", &B[i][j])); } } int minimum_instructions = minimumInstructions(N, M, K, C, A, B); printf("%d\n", minimum_instructions); return 0; }

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

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(j=0;j<S[C[i]].size();j++)
      |                 ~^~~~~~~~~~~~~~~
paint.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(j=0;j<S[C[i-1]].size();j++)
      |                 ~^~~~~~~~~~~~~~~~~
paint.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(j=0;j<S[C[i+M-1]].size();j++)
      |                 ~^~~~~~~~~~~~~~~~~~~
/tmp/ccH32PmN.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccCu4vEI.o:paint.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status