답안 #844601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844601 2023-09-05T14:29:46 Z vjudge1 Spiderman (COCI20_spiderman) C++17
0 / 70
5 ms 8336 KB
// Imagine not FFT
#include <bits/stdc++.h>
 
#ifndef ONLINE_JUDGE
    #define DEBUG(x) std::cerr << #x << ": " << x << std::endl;
    #define DEBUGV(x) std::cerr << #x << ": { "; for(auto ___y:x) std::cerr << ___y << " "; std::cerr << "}" << std::endl;
    #define DEBUGVV(x) std::cerr << #x << ": { \n"; for(int _i=0;_i<sz(x);++_i) {DEBUGV(x[_i]);} std::cerr << "}" << std::endl;
	#define DEBUGVP(x) std::cerr << #x << ": { "; for(auto ___y:x) std::cerr << "{" << ___y.first << "," << ___y.second << "}" << " "; std::cerr << "}" << std::endl;
	#define files freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    #define fastio std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
#else
    #define fastio std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
    #define DEBUG(...) void(23)
    #define DEBUGV(x) void(23);
    #define DEBUGARR(arr, size) void(23)
    #define DEBUGPRINT(...) void(23)
    #define DEBUGMAP(...) void(23)
    #define DEBUGMAPQUEUE(...) void(23)
    #define DEBUGVV(x) void(23);
    #define DEBUGVP(x) void(23);
    #define files void(23);
#endif

#define int long long
#define ll long long
 
#define pb push_back
#define ff first
#define ss second
#define pii std::pair < int , int >
#define pll std::pair < ll , ll >
#define vi std::vector < ll >
#define vl std::vector < int >
#define vii std::vector < pii >
#define vll std::vector < pll >
#define vvi std::vector < vi >
#define vvii std::vector < vii >
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define forn(i,j) for(int i=0;i<j;i++)
#define forr(i,j,k) for(int i=j;i<k;i++)
 
#define mset multiset
#define pqueue priority_queue
#define cmax(a,b) (a = max(a,b))
#define cmin(a,b) (a = min(a,b))
 
#define sz(a) (int)(a.size())
     
using namespace std;

map < int , int > done;
void solve(int _t_case){
	int n,k;
	cin >> n >> k;
	vii a(n);
	forn(i,n){
		cin >> a[i].first;
		a[i].second=i;
	}
	sort(all(a));
	map < int , int > b;
	vector < int > ans(n);
	vi from(1000005,0);
	for(auto c:a) ++b[c.ff];
    forn(_c,n) {
		auto c = a[_c];
		if(done[c.ff]==0 && c.ff>k){
			int inc = b[c.ff];
			for(int i=c.ff;i<1000005;i+=c.ff){
				from[i]+=inc;
			}
			done[c.ff]=1;
		}
		if(c.ff<k) ans[c.ss] = 0;
		else if(c.ff>k) ans[c.ss] = from[c.ff-k];
		else ans[c.ss] = n-_c-1;
	}
	DEBUGVP(b);
	for(auto an:ans) cout << an << " ";
	return;
}

signed main(){
    fastio;
    files;
    int t=1,_t=0;
//    std::cin >> t;
    while(_t<t){
        ++_t;
        solve(_t);
    }
    return 0;
}

Compilation message

spiderman.cpp: In function 'int main()':
spiderman.cpp:9:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  #define files freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
spiderman.cpp:86:5: note: in expansion of macro 'files'
   86 |     files;
      |     ^~~~~
spiderman.cpp:9:51: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  #define files freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
      |                                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
spiderman.cpp:86:5: note: in expansion of macro 'files'
   86 |     files;
      |     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 8284 KB Output isn't correct
2 Incorrect 3 ms 8284 KB Output isn't correct
3 Incorrect 3 ms 8336 KB Output isn't correct
4 Incorrect 3 ms 8280 KB Output isn't correct
5 Incorrect 3 ms 8284 KB Output isn't correct
6 Incorrect 3 ms 8284 KB Output isn't correct
7 Incorrect 5 ms 8280 KB Output isn't correct
8 Incorrect 3 ms 8284 KB Output isn't correct
9 Incorrect 3 ms 8284 KB Output isn't correct
10 Incorrect 3 ms 8284 KB Output isn't correct