제출 #386332

#제출 시각아이디문제언어결과실행 시간메모리
386332leinad2벽 칠하기 (APIO20_paint)C++17
51 / 100
1578 ms7532 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++; } }

컴파일 시 표준 에러 (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++)
      |                 ~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...