QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#336874 | #7398. Triangle Tiling | Kevin5307 | Compile Error | / | / | C++20 | 3.8kb | 2024-02-24 23:10:02 | 2024-02-24 23:10:02 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
char grid[5005][5005];
int val[5005][5005];
bool token[5005];
class segtree
{
public:
#define ls (x<<1)
#define rs (ls|1)
int mn[5005<<2];
int tag[5005<<2];
void build(int x,int l,int r)
{
mn[x]=0;
tag[x]=0;
if(l==r) return ;
int mid=(l+r)/2;
build(ls,l,mid);
build(rs,mid+1,r);
}
void pushdown(int x,int l,int r)
{
mn[x]+=tag[x];
if(l!=r)
{
tag[ls]+=tag[x];
tag[rs]+=tag[x];
}
tag[x]=0;
}
int query(int x,int l,int r,int ql,int qr)
{
pushdown(x,l,r);
if(l==ql&&r==qr)
return mn[x];
int mid=(l+r)/2;
if(qr<=mid)
return query(ls,l,mid,ql,qr);
if(ql>mid)
return query(rs,mid+1,r,ql,qr);
return min(query(ls,l,mid,ql,mid),query(rs,mid+1,r,mid+1,qr));
}
void pushup(int x,int l,int r)
{
int mid=(l+r)/2;
pushdown(ls,l,mid);
pushdown(rs,mid+1,r);
mn[x]=min(mn[ls],mn[rs]);
}
void update(int x,int l,int r,int ql,int qr,int v)
{
pushdown(x,l,r);
if(l==ql&&r==qr)
{
tag[x]+=v;
return ;
}
int mid=(l+r)/2;
if(ql<=mid)
update(ls,l,mid,ql,min(mid,qr),v);
if(qr>mid)
update(rs,mid+1,r,max(mid+1,ql),qr,v);
pushup(x,l,r);
}
#undef ls
#undef rs
}segt[5005];
char ans[5005][5005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>(grid[i]+1);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
val[i][j]=0;
vector<pii> vec;
for(int i=1;i<=n;i++)
for(int j=1;j<=i;j++)
if(grid[i][j]=='0')
{
ans[i][j]='-';
vec.pb(i,j);
val[j][j+n-i]++;
}
else
ans[i][j]='2';
if(sz(vec)!=n)
{
cout<<"Impossible!"<<endl;
continue;
}
for(int len=1;len<=n;len++)
for(int i=1,j=len;j<=n;i++,j++)
val[i][j]+=val[i+1][j]+val[i][j-1]-val[i+1][j-1];
bool flag=1;
for(int len=1;len<=n;len++)
for(int i=1,j=len;j<=n;i++,j++)
{
val[i][j]-=len;
if(val[i][j]>0)
flag=0;
val[i][j]=-val[i][j];
}
srt(vec);
for(int i=0;i<n;i++)
if(vec[i].first<=i)
flag=0;
if(!flag)
{
cout<<"Impossible!"<<endl;
continue;
}
memset(token,0,sizeof(token));
for(int i=1;i<=n;i++)
if(grid[n][i]=='1')
token[i]=1;
for(int i=1;i<=n;i++)
segt[i].build(1,1,n);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
segt[j].update(1,1,n,i,i,val[i][j]);
for(int i=n;i>1;i--)
{
static bool ntoken[5005];
memset(ntoken,0,sizeof(ntoken));
for(int j=1;j<=i;j++)
if(token[j])
{
int mn=segt[j+n-i].query(1,1,n,1,j);
if(mn)
{
assert(j!=i);
ntoken[j]=1;
segt[j+n-i].update(1,1,n,1,j,-1);
ans[i][j]='3';
}
else
{
int p=i;
while(p&&grid[p][j-(i-p)]=='1')
{
ans[p][j-(i-p)]='1';
p--;
}
assert(p);
for(int k=j+n-i;k<=n;k++)
segt[k].update(1,1,n,j-(i-p)+1,j,-1);
}
}
memcpy(token,ntoken,sizeof(token));
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
cout<<ans[i][j];
cout<<endl;
}
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:101:28: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’) 101 | cin>>(grid[i]+1); | ~~~^~~~~~~~~~~~~ | | | | | char* | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127, from answer.code:2: /usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 325 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/13/istream:325:7: note: conversion of argument 1 would be ill-formed: answer.code:101:38: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’ 101 | cin>>(grid[i]+1); | ~~~~~~~~^~~ /usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 201 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:201:7: note: conversion of argument 1 would be ill-formed: answer.code:101:38: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive] 101 | cin>>(grid[i]+1); | ~~~~~~~~^~~ | | | char* answer.code:101:38: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& grid[i])) + 1)’ to ‘long long unsigned int&’ /usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 197 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:197:7: note: conversion of argument 1 would be ill-formed: answer.code:101:38: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive] 101 | cin>>(grid[i]+1); | ~~~~~~~~^~~ | | | char* answer.code:101:38: error: cannot bind rvalue ‘(long long int)(((char*)(& grid[i])) + 1)’ to ‘long long int&’ /usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:192:7: note: conversion of argument 1 would be ill-formed: answer.code:101:38: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive] 101 | cin>>(grid[i]+1); | ~~~~~~~~^~~ | | | char* answer.code:101:38: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& grid[i])) + 1)’ to ‘long unsigned int&’ /usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:188:7: note: conversion of argument 1 would be ill-formed: answer.code:101:38: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive] 101 | cin>>(grid[i]+1); | ~~~~~~~~^~~ | | | char* answer.code:101:38: error: cannot bind rvalue ‘(long int)(((char*)(& grid[i])) + 1)’ to ‘long int&’ /usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<cha...