이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define F first
#define S second
#define sz(x) (ll)x.size()
#define pb push_back
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i= 0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
long long ans;
vector <vi> vis;
void init(ll m){
vis.assign(m, vi(m));
ans = 0;
}
void mark_vis(ll x, ll y){
// dbg2(x,y);
if (!vis[x][y]){
vis[x][y] = 1;
ans++;
}
}
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
init(m);
for (ll i =0; i<n; i++){
ll x = r[i], y = c[i];
// dbg3(i,x,y);
ll val = x + y;
bool direction = (x > y); //true if down-left
ll squareDimensions = abs(x-y) + 1;
// dbg2(direction, squareDimensions);
for (ll j = 0; j<squareDimensions; j++){
for (ll k = 0; k<squareDimensions; k++){
if (direction) mark_vis(x-k, y+j);
else mark_vis(x+k, y-j);
}
}
}
return ans;
}
/*
5 7 5
0 3
4 4
4 6
4 5
4 6
*/
컴파일 시 표준 에러 (stderr) 메시지
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:48:12: warning: unused variable 'val' [-Wunused-variable]
48 | ll val = x + y;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |