Submission #113215

#TimeUsernameProblemLanguageResultExecution timeMemory
113215tutisSpirale (COCI18_spirale)C++17
80 / 80
147 ms604 KiB
/*input 4 3 2 1 1 0 1 2 0 */ #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #include <bits/stdc++.h> using namespace std; typedef long long ll; const int sz = 111 * 111; int ans[50][50]; int dx[sz], dy[sz]; int main() { ios_base::sync_with_stdio(false); int N, M, K; cin >> N >> M >> K; int x[K], y[K], t[K]; for (int i = 0; i < K; i++) { cin >> y[i] >> x[i] >> t[i]; x[i]--; y[i]--; } dx[0] = dy[0] = 0; int tim = 1; int a = 0; int b = 0; for (int d = 1; d <= 50; d++) { b++; a--; for (int c = 0; c <= 2 * d - 1; c++) { a++; dx[tim] = a; dy[tim] = b; tim++; } for (int c = 0; c <= 2 * d - 1; c++) { b--; dx[tim] = a; dy[tim] = b; tim++; } for (int c = 0; c <= 2 * d - 1; c++) { a--; dx[tim] = a; dy[tim] = b; tim++; } for (int c = 0; c <= 2 * d - 1; c++) { b++; dx[tim] = a; dy[tim] = b; tim++; } } for (int id = 0; id < sz; id++) { for (int i = 0; i < K; i++) { int yy = -dy[id] + y[i]; int xx = -(t[i] * 2 - 1) * (dx[id]) + x[i]; if (xx >= 0 && xx < M && yy >= 0 && yy < N && ans[yy][xx] == 0) ans[yy][xx] = id + 1; } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cout << ans[i][j] << " "; } cout << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...