답안 #334960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334960 2020-12-10T13:02:15 Z amunduzbaev Nice sequence (IZhO18_sequence) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
 
int len, n, m, pref[N];
bool vis[N];
vector<int>top;
 
void dfs(int v){
	vis[v] = 1;
    if(v - m >= 0 && !vis[v - m]) dfs(v - m);
    if(v + n <= len && !vis[v + n]) dfs(v + n);
    top.push_back(v);
}
 
bool check(int x){
	len=x;
    top.clear();
    for(int i = 0; i <= len; i++) vis[i] = 0;
    for(int i = 0; i <= len; i++) if(!vis[i]) dfs(i);
    for(int i = 0; i <= len; i++) pref[ top[i] ] = i;
    for(int i = 0; i <= len; i++){
        if(i - m >= 0 && pref[i] <= pref[i - m]) return false;
        if(i + n <= len && pref[i] <= pref[i + n]) return false;
    }
    return true;
}
 
void solve(){
	scanf("%d %d", &n, &m);
	int l = 0, r = 400000;
	
	while(l < r){
		int mid = (l+r+1) >> 1;
		if(check(mid)) l = mid;
		else r = mid-1;
	}
	check(l);
  printf("%d\n", l);
	if(l){
		for(int i=1;i<=l;i++) pritnf("%d ", pref[i] - pref[i-1]);
		printf("\n");
	}
	return;
}
 
int main(){
	int t;
	scanf("%d", &t);
	while(t--) solve();
	return 0;
}
 

Compilation message

sequence.cpp: In function 'void solve()':
sequence.cpp:57:25: error: 'pritnf' was not declared in this scope; did you mean 'printf'?
   57 |   for(int i=1;i<=l;i++) pritnf("%d ", pref[i] - pref[i-1]);
      |                         ^~~~~~
      |                         printf
sequence.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
sequence.cpp: In function 'int main()':
sequence.cpp:65:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   65 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~