제출 #350909

#제출 시각아이디문제언어결과실행 시간메모리
350909Hossein8320Spiral (BOI16_spiral)C++17
0 / 100
79 ms63116 KiB
// That's what she said ! #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> const int maxn = 2e3 + 9 , modn = 1e9 + 7; int n, ps[maxn][maxn], a[maxn][maxn], m, q, w, e, r; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; a[n+1][n+1] = 1; int i = n+1 , j = n+1, k = 1, val = 2, x, y; n = 2 * n + 1; while(val <= n * n){ if(k % 2){ j++; x = j + k; for(j; j < x; j++){ a[i][j] = val; val++; } j--, i--; y = i - k; for(i; i > y; i--){ a[i][j] = val; val++; } i++; } else{ j--; x = j - k; for(j; j > x; j--){ a[i][j] = val; val++; } j++, i++; y = i + k; for(i; i < y; i++){ a[i][j] = val; val++; } i--; } k++; } for(int i = n; i > 0; i--) for(int j = 1; j <= n; j++) ps[n-i+1][j] = ps[n-i][j] + ps[n-i+1][j-1] - ps[n-i][j-1] + a[i][j]; cin >> m; while(m --){ cin >> q >> w >> e >> r; q += n/2+1, w += n/2+1, e += n/2+1, r += n/2+1; cout << ps[r][e] - ps[r][q-1] - ps[w-1][e] + ps[w-1][q-1] << endl; } return 0; }

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

spiral.cpp: In function 'int32_t main()':
spiral.cpp:23:17: warning: statement has no effect [-Wunused-value]
   23 |             for(j; j < x; j++){
      |                 ^
spiral.cpp:29:17: warning: statement has no effect [-Wunused-value]
   29 |             for(i; i > y; i--){
      |                 ^
spiral.cpp:38:17: warning: statement has no effect [-Wunused-value]
   38 |             for(j; j > x; j--){
      |                 ^
spiral.cpp:44:17: warning: statement has no effect [-Wunused-value]
   44 |             for(i; i < y; i++){
      |                 ^
#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...