답안 #887416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887416 2023-12-14T13:21:59 Z pcc Nice sequence (IZhO18_sequence) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std; 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt") 
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 4e5+10;int n,m;vector<int> paths[mxn];int deg[mxn];queue<int> q;int arr[mxn];map<pii,int> mp; inline bool check(int tar){	for(int i = 0;i+n<=tar;i++){		paths[i+n].push_back(i);		deg[i]++;	}	for(int i = 0;i+m<=tar;i++){		paths[i].push_back(i+m);		deg[i+m]++;	}	for(int i = 0;i<=tar;i++){		if(!deg[i])q.push(i);	}	int p = 0;	while(!q.empty()){		auto now = q.front();		arr[now] = ++p;		q.pop();		for(auto nxt:paths[now]){			deg[nxt]--;			if(!deg[nxt])q.push(nxt);		}	}	for(int i = 0;i<=tar;i++){		paths[i].clear();		deg[i] = 0;	}		return p == tar+1;} inline void solve(){	cin>>n>>m;	int l = 0,r = max(n,m)*2;	if(mp.find({n,m}) != mp.end()){		l = r = mp[make_pair(n,m)];	}    l = r = n+m-__gcd(n,m)-1;	while(l != r){		int mid = (l+r+1)>>1;		if(check(mid))l = mid;		else r = mid-1;	}	check(l);	cout<<l<<endl;    return;		mp[make_pair(n,m)] = l;	for(int i  =1;i<=l;i++)cout<<arr[i]-arr[i-1]<<' ';cout<<'\n';	return;} int main(){	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	int t;cin>>t;	while(t--)solve();}

Compilation message

sequence.cpp:11:686: error: extended character   is not valid in an identifier
   11 | const int mxn = 4e5+10;int n,m;vector<int> paths[mxn];int deg[mxn];queue<int> q;int arr[mxn];map<pii,int> mp; inline bool check(int tar){ for(int i = 0;i+n<=tar;i++){  paths[i+n].push_back(i);  deg[i]++; } for(int i = 0;i+m<=tar;i++){  paths[i].push_back(i+m);  deg[i+m]++; } for(int i = 0;i<=tar;i++){  if(!deg[i])q.push(i); } int p = 0; while(!q.empty()){  auto now = q.front();  arr[now] = ++p;  q.pop();  for(auto nxt:paths[now]){   deg[nxt]--;   if(!deg[nxt])q.push(nxt);  } } for(int i = 0;i<=tar;i++){  paths[i].clear();  deg[i] = 0; }  return p == tar+1;} inline void solve(){ cin>>n>>m; int l = 0,r = max(n,m)*2; if(mp.find({n,m}) != mp.end()){  l = r = mp[make_pair(n,m)]; }    l = r = n+m-__gcd(n,m)-1; while(l != r){  int mid = (l+r+1)>>1;  if(check(mid))l = mid;  else r = mid-1; } check(l); cout<<l<<endl;    return;  mp[make_pair(n,m)] = l; for(int i  =1;i<=l;i++)cout<<arr[i]-arr[i-1]<<' ';cout<<'\n'; return;} int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--)solve();}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ^
sequence.cpp:11:822: error: extended character   is not valid in an identifier
   11 | const int mxn = 4e5+10;int n,m;vector<int> paths[mxn];int deg[mxn];queue<int> q;int arr[mxn];map<pii,int> mp; inline bool check(int tar){ for(int i = 0;i+n<=tar;i++){  paths[i+n].push_back(i);  deg[i]++; } for(int i = 0;i+m<=tar;i++){  paths[i].push_back(i+m);  deg[i+m]++; } for(int i = 0;i<=tar;i++){  if(!deg[i])q.push(i); } int p = 0; while(!q.empty()){  auto now = q.front();  arr[now] = ++p;  q.pop();  for(auto nxt:paths[now]){   deg[nxt]--;   if(!deg[nxt])q.push(nxt);  } } for(int i = 0;i<=tar;i++){  paths[i].clear();  deg[i] = 0; }  return p == tar+1;} inline void solve(){ cin>>n>>m; int l = 0,r = max(n,m)*2; if(mp.find({n,m}) != mp.end()){  l = r = mp[make_pair(n,m)]; }    l = r = n+m-__gcd(n,m)-1; while(l != r){  int mid = (l+r+1)>>1;  if(check(mid))l = mid;  else r = mid-1; } check(l); cout<<l<<endl;    return;  mp[make_pair(n,m)] = l; for(int i  =1;i<=l;i++)cout<<arr[i]-arr[i-1]<<' ';cout<<'\n'; return;} int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--)solve();}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ^
sequence.cpp: In function 'void solve()':
sequence.cpp:11:686: error: '\U000000a0' was not declared in this scope
   11 | const int mxn = 4e5+10;int n,m;vector<int> paths[mxn];int deg[mxn];queue<int> q;int arr[mxn];map<pii,int> mp; inline bool check(int tar){ for(int i = 0;i+n<=tar;i++){  paths[i+n].push_back(i);  deg[i]++; } for(int i = 0;i+m<=tar;i++){  paths[i].push_back(i+m);  deg[i+m]++; } for(int i = 0;i<=tar;i++){  if(!deg[i])q.push(i); } int p = 0; while(!q.empty()){  auto now = q.front();  arr[now] = ++p;  q.pop();  for(auto nxt:paths[now]){   deg[nxt]--;   if(!deg[nxt])q.push(nxt);  } } for(int i = 0;i<=tar;i++){  paths[i].clear();  deg[i] = 0; }  return p == tar+1;} inline void solve(){ cin>>n>>m; int l = 0,r = max(n,m)*2; if(mp.find({n,m}) != mp.end()){  l = r = mp[make_pair(n,m)]; }    l = r = n+m-__gcd(n,m)-1; while(l != r){  int mid = (l+r+1)>>1;  if(check(mid))l = mid;  else r = mid-1; } check(l); cout<<l<<endl;    return;  mp[make_pair(n,m)] = l; for(int i  =1;i<=l;i++)cout<<arr[i]-arr[i-1]<<' ';cout<<'\n'; return;} int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--)solve();}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ^
sequence.cpp:11:824: error: expected ';' before 'return'
   11 | const int mxn = 4e5+10;int n,m;vector<int> paths[mxn];int deg[mxn];queue<int> q;int arr[mxn];map<pii,int> mp; inline bool check(int tar){ for(int i = 0;i+n<=tar;i++){  paths[i+n].push_back(i);  deg[i]++; } for(int i = 0;i+m<=tar;i++){  paths[i].push_back(i+m);  deg[i+m]++; } for(int i = 0;i<=tar;i++){  if(!deg[i])q.push(i); } int p = 0; while(!q.empty()){  auto now = q.front();  arr[now] = ++p;  q.pop();  for(auto nxt:paths[now]){   deg[nxt]--;   if(!deg[nxt])q.push(nxt);  } } for(int i = 0;i<=tar;i++){  paths[i].clear();  deg[i] = 0; }  return p == tar+1;} inline void solve(){ cin>>n>>m; int l = 0,r = max(n,m)*2; if(mp.find({n,m}) != mp.end()){  l = r = mp[make_pair(n,m)]; }    l = r = n+m-__gcd(n,m)-1; while(l != r){  int mid = (l+r+1)>>1;  if(check(mid))l = mid;  else r = mid-1; } check(l); cout<<l<<endl;    return;  mp[make_pair(n,m)] = l; for(int i  =1;i<=l;i++)cout<<arr[i]-arr[i-1]<<' ';cout<<'\n'; return;} int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--)solve();}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ^ ~~~~~~
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ;