Submission #395556

#TimeUsernameProblemLanguageResultExecution timeMemory
395556SugardorjPainting Walls (APIO20_paint)C++14
0 / 100
1 ms308 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; int i,j,s,t; int c[234567],a[234567],l=12345678,r,tt,k,y,z,n,m,x; pair<int,pair<int,int>>p[234567]; int minimumInstructions(int n, int m, int K, vector<int> C,vector<int> A, vector<vector<int>> B){ for (i = 0; i <m; i ++){ for (auto u:B[i]){ a[u]=i; } } s= 0; if (n%m==0){ while (s<n){ x = a[C[s]]; for (i = s; i<s+m; i ++){ if (a[C[i]]!=(x+i-s)%m) return -1; } s+=m; } return n/m; } else { x = a[C[0]]; for (i = 0; i <n; i ++){ if (a[C[i]]!=(x+i)%m) return -1; } return n/m+1; } }
#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...